So in the convolutional neural network cifar10 example in tensorflow, in the inference()
method of cifar10.py I see several instances of this:
bias = tf.reshape(tf.nn.bias_add(conv, biases),conv.get_shape().as_list())
It seems like the reshape is making sure the output of bias_add(value, bias)
has the shape of value
My question is, is the tf.reshape()
necessary? Is there a situation where tf.nn.bias_add(value, bias)
will not return a tensor with the same shape as value?
The shape of the result of tf.nn.bias_add(value, bias)
is always the same as the shape of value, so these calls to tf.reshape()
are unnecessary.
Occasionally, calls to tf.reshape()
are used to add explicit information about the shape, but the recommended way to do this, per the FAQ, is to use the Tensor.set_shape()
method to add shape information without adding a redundant operation to the graph.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With