Merge branch 'master' into dev-woj

main
ziembla 2017-11-30 06:28:52 +01:00
commit 4453715759
1 changed files with 6 additions and 6 deletions

View File

@ -512,10 +512,10 @@
"We can apply this function to compute $\\hat{\\mathbf{u}}_{j|i}$ for every pair of capsules ($i$, $j$) like this (recall that there are 6×6×32=1152 capsules in the first layer, and 10 in the second layer):\n",
"$\n",
"\\pmatrix{\n",
" \\mathbf{W}_{1,1} & \\mathbf{W}_{2,1} & \\cdots & \\mathbf{W}_{10,1} \\\\\n",
" \\mathbf{W}_{1,2} & \\mathbf{W}_{2,2} & \\cdots & \\mathbf{W}_{10,2} \\\\\n",
" \\mathbf{W}_{1,1} & \\mathbf{W}_{1,2} & \\cdots & \\mathbf{W}_{1,10} \\\\\n",
" \\mathbf{W}_{2,1} & \\mathbf{W}_{2,2} & \\cdots & \\mathbf{W}_{2,10} \\\\\n",
" \\vdots & \\vdots & \\ddots & \\vdots \\\\\n",
" \\mathbf{W}_{1,1152} & \\mathbf{W}_{2,1152} & \\cdots & \\mathbf{W}_{10,1152}\n",
" \\mathbf{W}_{1152,1} & \\mathbf{W}_{1152,2} & \\cdots & \\mathbf{W}_{1152,10}\n",
"} \\times\n",
"\\pmatrix{\n",
" \\mathbf{u}_1 & \\mathbf{u}_1 & \\cdots & \\mathbf{u}_1 \\\\\n",
@ -1434,7 +1434,7 @@
"source": [
"Note that the `tf.cond()` function expects the if-True and if-False tensors to be passed _via_ functions: these functions will be called just once during the graph construction phase (not during the execution phase), similar to `tf.while_loop()`. This allows TensorFlow to add the necessary operations to handle the conditional evaluation of the if-True or if-False tensors. However, in our case, the tensors `y` and `y_pred` are already created by the time we call `tf.cond()`, so unfortunately TensorFlow will consider both `y` and `y_pred` to be dependencies of the `reconstruction_targets` tensor. The `reconstruction_targets` tensor will end up with the correct value, but:\n",
"1. whenever we evaluate a tensor that depends on `reconstruction_targets`, the `y_pred` tensor will be evaluated (even if `mask_with_layers` is `True`). This is not a big deal because computing `y_pred` adds no computing overhead during training, since we need it anyway to compute the margin loss. And during testing, if we are doing classification, we won't need reconstructions, so `reconstruction_targets` won't be evaluated at all.\n",
"2. we will always need to feed a value for the `y` placeholder (even if `mask_with_layers` is `False`). This is a bit annoying, but we can pass any array of the appropriate shape, because TensorFlow won't use it anyway (it just does not know it yet when it checks for dependencies)."
"2. we will always need to feed a value for the `y` placeholder (even if `mask_with_layers` is `False`). This is a bit annoying, but we can pass an empty array, because TensorFlow won't use it anyway (it just does not know it yet when it checks for dependencies)."
]
},
{
@ -1935,14 +1935,14 @@
" caps2_output_value, decoder_output_value, y_pred_value = sess.run(\n",
" [caps2_output, decoder_output, y_pred],\n",
" feed_dict={X: sample_images,\n",
" y: np.full(n_samples, np.nan)})"
" y: np.array([], dtype=np.int64)})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note: we feed `y` with an array of the appropriate size (full of `nan` values), but TensorFlow will not use it, as explained earlier."
"Note: we feed `y` with an empty array, but TensorFlow will not use it, as explained earlier."
]
},
{