Skip to content

Commit 3e1cfdc

Browse files
committed
move weight dict definition above network definition
1 parent 667555d commit 3e1cfdc

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

notebooks/live_training/deep_net_in_tensorflow_LT.ipynb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"cell_type": "markdown",
144144
"metadata": {},
145145
"source": [
146-
"#### Design neural network architecture"
146+
"#### Define dictionaries for storing weights and biases for each layer -- and initialize"
147147
]
148148
},
149149
{
@@ -154,18 +154,24 @@
154154
},
155155
"outputs": [],
156156
"source": [
157-
"def network(x, weights, biases):\n",
158-
" \n",
159-
" # DEFINE\n",
160-
" \n",
161-
" return out_layer_z"
157+
"bias_dict = {\n",
158+
" 'b1': tf.Variable(tf.zeros([n_dense_1])), \n",
159+
" 'b2': tf.Variable(tf.zeros([n_dense_2])),\n",
160+
" 'b_out': tf.Variable(tf.zeros([n_classes]))\n",
161+
"}\n",
162+
"\n",
163+
"weight_dict = {\n",
164+
" 'W1': tf.get_variable('W1', [n_input, n_dense_1], initializer=weight_initializer),\n",
165+
" 'W2': tf.get_variable('W2', [n_dense_1, n_dense_2], initializer=weight_initializer),\n",
166+
" 'W_out': tf.get_variable('W_out', [n_dense_2, n_classes], initializer=weight_initializer)\n",
167+
"}"
162168
]
163169
},
164170
{
165171
"cell_type": "markdown",
166172
"metadata": {},
167173
"source": [
168-
"#### Define dictionaries for storing weights and biases for each layer -- and initialize"
174+
"#### Design neural network architecture"
169175
]
170176
},
171177
{
@@ -176,17 +182,11 @@
176182
},
177183
"outputs": [],
178184
"source": [
179-
"bias_dict = {\n",
180-
" 'b1': tf.Variable(tf.zeros([n_dense_1])), \n",
181-
" 'b2': tf.Variable(tf.zeros([n_dense_2])),\n",
182-
" 'b_out': tf.Variable(tf.zeros([n_classes]))\n",
183-
"}\n",
184-
"\n",
185-
"weight_dict = {\n",
186-
" 'W1': tf.get_variable('W1', [n_input, n_dense_1], initializer=weight_initializer),\n",
187-
" 'W2': tf.get_variable('W2', [n_dense_1, n_dense_2], initializer=weight_initializer),\n",
188-
" 'W_out': tf.get_variable('W_out', [n_dense_2, n_classes], initializer=weight_initializer)\n",
189-
"}"
185+
"def network(x, weights, biases):\n",
186+
" \n",
187+
" # DEFINE\n",
188+
" \n",
189+
" return out_layer_z"
190190
]
191191
},
192192
{
@@ -336,7 +336,7 @@
336336
"name": "python",
337337
"nbconvert_exporter": "python",
338338
"pygments_lexer": "ipython3",
339-
"version": "3.6.1"
339+
"version": "3.6.2"
340340
}
341341
},
342342
"nbformat": 4,

0 commit comments

Comments
 (0)