次のようなテンソルを定義します。
x = tf.get_variable("x", [100])
しかし、テンソルの形状を印刷しようとすると:
print( tf.shape(x) )
Tensor("Shape:0", shape=(1,), dtype=int32) を取得します。出力の結果が shape=(100) にならない理由
次のようなテンソルを定義します。
x = tf.get_variable("x", [100])
しかし、テンソルの形状を印刷しようとすると:
print( tf.shape(x) )
Tensor("Shape:0", shape=(1,), dtype=int32) を取得します。出力の結果が shape=(100) にならない理由
tf.shape(input, name=None)は、入力の形状を表す 1-D 整数テンソルを返します。
探しているもの:変数のx.get_shape()
を返します。TensorShape
x
更新: この回答のために、Tensorflow の動的/静的形状を明確にする記事を書きました: https://pgaleone.eu/tensorflow/2018/07/28/understanding-tensorflow-tensors-shape-static-dynamic/