0

Defined a model which takes input of shape(96,96,3) and outputs shape(128) i.e. gives an embedding of 128 size for a given image of input size. Similar to facenet

createmodel() is the function which returns the full model after constructing it. Since the model expects input in the form of (batch_size,96,96,3) I pass 3 images i.e. (3,96,96,3) so the output of the model will be of shape(1,3,128). Keeping that in mind consider the following:

nn4_small2=createmodel()
print(nn4_small2.outputs[0][2])

#prints Tensor("strided_slice_11:0", shape=(128,), dtype=float32)

x=nn4_small2.outputs[0][2]
print(tf.shape(x))

#prints Tensor("Shape_6:0", shape=(1,), dtype=int32)

Why does the shape of the output tensor change when assigned to a variable?

yolob 21
  • 385
  • 4
  • 19

1 Answers1

0

Relevant post

tf.shape(input, name=None) returns a 1-D integer tensor representing the shape of input.

using x.get_shape() returns the TensorShape of the x variable.

Community
  • 1
  • 1
yolob 21
  • 385
  • 4
  • 19