Skip to content

Commit ef0ecec

Browse files
authored
Merge pull request #168 from vijaykyr/master
Lab Maintenance
2 parents 9852e44 + e59b167 commit ef0ecec

File tree

14 files changed

+932
-843
lines changed

14 files changed

+932
-843
lines changed

courses/machine_learning/deepdive/03_tensorflow/a_tfstart.ipynb

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"cell_type": "code",
17-
"execution_count": 1,
17+
"execution_count": 3,
1818
"metadata": {
1919
"collapsed": false,
2020
"deletable": true,
@@ -25,15 +25,15 @@
2525
"name": "stdout",
2626
"output_type": "stream",
2727
"text": [
28-
"1.4.1\n"
28+
"1.7.0\n"
2929
]
3030
}
3131
],
3232
"source": [
3333
"import tensorflow as tf\n",
3434
"import numpy as np\n",
3535
"\n",
36-
"print tf.__version__"
36+
"print(tf.__version__)"
3737
]
3838
},
3939
{
@@ -50,7 +50,7 @@
5050
},
5151
{
5252
"cell_type": "code",
53-
"execution_count": 2,
53+
"execution_count": 4,
5454
"metadata": {
5555
"collapsed": false,
5656
"deletable": true,
@@ -86,7 +86,7 @@
8686
},
8787
{
8888
"cell_type": "code",
89-
"execution_count": 3,
89+
"execution_count": 5,
9090
"metadata": {
9191
"collapsed": false,
9292
"deletable": true,
@@ -130,7 +130,7 @@
130130
},
131131
{
132132
"cell_type": "code",
133-
"execution_count": 4,
133+
"execution_count": 6,
134134
"metadata": {
135135
"collapsed": false,
136136
"deletable": true,
@@ -165,7 +165,7 @@
165165
},
166166
{
167167
"cell_type": "code",
168-
"execution_count": 5,
168+
"execution_count": 9,
169169
"metadata": {
170170
"collapsed": false,
171171
"deletable": true,
@@ -208,7 +208,7 @@
208208
},
209209
{
210210
"cell_type": "code",
211-
"execution_count": 6,
211+
"execution_count": 10,
212212
"metadata": {
213213
"collapsed": false,
214214
"deletable": true,
@@ -259,7 +259,7 @@
259259
},
260260
{
261261
"cell_type": "code",
262-
"execution_count": 7,
262+
"execution_count": 11,
263263
"metadata": {
264264
"collapsed": false,
265265
"deletable": true,
@@ -312,19 +312,30 @@
312312
"editable": true
313313
},
314314
"outputs": [
315+
{
316+
"name": "stderr",
317+
"output_type": "stream",
318+
"text": [
319+
"/usr/local/envs/py2env/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
320+
" from ._conv import register_converters as _register_converters\n"
321+
]
322+
},
315323
{
316324
"name": "stdout",
317325
"output_type": "stream",
318326
"text": [
327+
"WARNING:tensorflow:From /usr/local/envs/py2env/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.\n",
328+
"Instructions for updating:\n",
329+
"Use the retry module or similar alternatives.\n",
319330
"tf.Tensor([6.278497 4.709139], shape=(2,), dtype=float32)\n"
320331
]
321332
}
322333
],
323334
"source": [
324335
"import tensorflow as tf\n",
325-
"from tensorflow.contrib.eager.python import tfe\n",
336+
"import tensorflow.contrib.eager as tfe\n",
326337
"\n",
327-
"tfe.enable_eager_execution()\n",
338+
"tf.enable_eager_execution()\n",
328339
"\n",
329340
"def compute_area(sides):\n",
330341
" # slice the input to get the sides\n",
@@ -348,7 +359,10 @@
348359
},
349360
{
350361
"cell_type": "markdown",
351-
"metadata": {},
362+
"metadata": {
363+
"deletable": true,
364+
"editable": true
365+
},
352366
"source": [
353367
"## Challenge Exercise\n",
354368
"\n",

courses/machine_learning/deepdive/03_tensorflow/b_estimator.ipynb

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"editable": true
6868
},
6969
"source": [
70-
"<h2> Input function to read from Pandas Dataframe </h2>"
70+
"<h2> Input functions to read from Pandas Dataframe </h2>"
7171
]
7272
},
7373
{
@@ -92,6 +92,38 @@
9292
" )"
9393
]
9494
},
95+
{
96+
"cell_type": "markdown",
97+
"metadata": {
98+
"deletable": true,
99+
"editable": true
100+
},
101+
"source": [
102+
"Our input function for predictions is the same except we don't provide a label"
103+
]
104+
},
105+
{
106+
"cell_type": "code",
107+
"execution_count": null,
108+
"metadata": {
109+
"collapsed": true,
110+
"deletable": true,
111+
"editable": true
112+
},
113+
"outputs": [],
114+
"source": [
115+
"def make_prediction_input_fn(df, num_epochs):\n",
116+
" return tf.estimator.inputs.pandas_input_fn(\n",
117+
" x = df,\n",
118+
" y = None,\n",
119+
" batch_size = 128,\n",
120+
" num_epochs = num_epochs,\n",
121+
" shuffle = True,\n",
122+
" queue_capacity = 1000,\n",
123+
" num_threads = 1\n",
124+
" )"
125+
]
126+
},
95127
{
96128
"cell_type": "markdown",
97129
"metadata": {
@@ -194,12 +226,9 @@
194226
},
195227
"outputs": [],
196228
"source": [
197-
"import itertools\n",
198-
"# Read saved model and use it for prediction\n",
199-
"model = tf.estimator.LinearRegressor(\n",
200-
" feature_columns = make_feature_cols(), model_dir = OUTDIR)\n",
201-
"preds_iter = model.predict(input_fn = make_input_fn(df_valid, 1))\n",
202-
"print([pred['predictions'][0] for pred in list(itertools.islice(preds_iter, 5))])"
229+
"predictions = model.predict(input_fn = make_prediction_input_fn(df_valid, 1))\n",
230+
"for i in xrange(5):\n",
231+
" print(predictions.next())"
203232
]
204233
},
205234
{
@@ -357,7 +386,10 @@
357386
},
358387
{
359388
"cell_type": "markdown",
360-
"metadata": {},
389+
"metadata": {
390+
"deletable": true,
391+
"editable": true
392+
},
361393
"source": [
362394
"## Challenge Exercise\n",
363395
"\n",
@@ -386,21 +418,21 @@
386418
],
387419
"metadata": {
388420
"kernelspec": {
389-
"display_name": "Python 3",
421+
"display_name": "Python 2",
390422
"language": "python",
391-
"name": "python3"
423+
"name": "python2"
392424
},
393425
"language_info": {
394426
"codemirror_mode": {
395427
"name": "ipython",
396-
"version": 3
428+
"version": 2
397429
},
398430
"file_extension": ".py",
399431
"mimetype": "text/x-python",
400432
"name": "python",
401433
"nbconvert_exporter": "python",
402-
"pygments_lexer": "ipython3",
403-
"version": "3.5.5"
434+
"pygments_lexer": "ipython2",
435+
"version": "2.7.14"
404436
}
405437
},
406438
"nbformat": 4,

courses/machine_learning/deepdive/03_tensorflow/c_dataset.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@
200200
},
201201
{
202202
"cell_type": "markdown",
203-
"metadata": {},
203+
"metadata": {
204+
"deletable": true,
205+
"editable": true
206+
},
204207
"source": [
205208
"## Challenge Exercise\n",
206209
"\n",

courses/machine_learning/deepdive/03_tensorflow/d_traineval.ipynb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@
300300
},
301301
{
302302
"cell_type": "markdown",
303-
"metadata": {},
303+
"metadata": {
304+
"deletable": true,
305+
"editable": true
306+
},
304307
"source": [
305308
"## Challenge Exercise\n",
306309
"\n",

0 commit comments

Comments
 (0)