Skip to content

Commit

Permalink
batch gen consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
rasbt committed Sep 19, 2017
1 parent 93746ed commit 85156a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
19 changes: 13 additions & 6 deletions code/ch13/ch13.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@
" training_loss = []\n",
" batch_generator = create_batch_generator(\n",
" X_train_centered, y_train, \n",
" batch_size=64, shuffle=True)\n",
" batch_size=64)\n",
" for batch_X, batch_y in batch_generator:\n",
" ## prepare a dict to feed data to our network:\n",
" feed = {tf_x:batch_X, tf_y:batch_y}\n",
Expand Down Expand Up @@ -1389,11 +1389,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[NbConvertApp] Converting notebook ch13.ipynb to script\n",
"[NbConvertApp] Writing 18184 bytes to ch13.py\n"
]
}
],
"source": [
"! python ../.convert_notebook_to_script.py --input ch13.ipynb --output ch13.py"
]
Expand Down
9 changes: 7 additions & 2 deletions code/ch13/ch13.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def create_batch_generator(X, y, batch_size=128, shuffle=False):
y_copy = data[:, -1].astype(int)

for i in range(0, X.shape[0], batch_size):
yield (X[i:i+batch_size, :], y[i:i+batch_size])
yield (X_copy[i:i+batch_size, :], y_copy[i:i+batch_size])



Expand All @@ -413,7 +413,7 @@ def create_batch_generator(X, y, batch_size=128, shuffle=False):
training_loss = []
batch_generator = create_batch_generator(
X_train_centered, y_train,
batch_size=64, shuffle=True)
batch_size=64)
for batch_X, batch_y in batch_generator:
## prepare a dict to feed data to our network:
feed = {tf_x:batch_X, tf_y:batch_y}
Expand Down Expand Up @@ -668,3 +668,8 @@ def tanh(z):








0 comments on commit 85156a2

Please sign in to comment.