input_shape = [None, 28, 28, 1]
x = tf.placeholder( tf.float32, input_shape, name='x')
--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+unsubscribe@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/afd87f0f-015c-4f71-8351-bcfa5e56b32a%40tensorflow.org.
corrupt_attr = tf.random_uniform(shape=shape,
minval=0,
maxval=2,
dtype=tf.int32) ### TODO fix the bug for 4-d tensor corrupt
casted_attr = tf.cast(corrupt_attr, tf.float32)
corrupt_tensor = tf.mul(x, casted_attr)
--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/8532ea89-e0c2-443b-b073-683bad693627%40tensorflow.org.
tf.Tensor.get_shape(), can be used to infer output using the operation that created it, means we can infer it without using sess.run() (running the operation), as hinted by the name, static shape. For example,
c=tf.random_uniform([1,3,1,1])
is a tf.Tensor, and we want to know its shape at any step in the code, before running the graph, so we can use
c.get_shape()
The reason of tf.Tensor.get_shape unable to be dynamic (sess.run()) is because of the output type TensorShape instead of tf.tensor, outputting the TensorShape restricts the usage of sess.run().
sess.run(c.get_shape())
if we do we get an error that TensorShape has an invalid type it must be a Tensor/operation or a string.
On the other hand, the dynamic shape needs the operation to be run via sess.run() to get the shape
sess.run(tf.shape(c))
Output: array([1, 3, 1, 1])
or
sess.run(c).shape
(1, 3, 1, 1) # tuple
Hope it helps to clarify tensorflow concepts.