Tensor with unspecified dimension in tensorflow

前端 未结 3 778
广开言路
广开言路 2020-12-14 02:03

I\'m playing around with tensorflow and ran into a problem with the following code:

def _init_parameters(self, input_data, labels):

    # the input shape is         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-14 02:43

    The variable can have a dynamic shape. get_shape() returns the static shape.

    In your case you have a tensor that has a dynamic shape, and currently happens to hold value that is 4x3 (but at some other time it can hold a value with a different shape -- because the shape is dynamic). To set the static shape, use set_shape(w_shape). After that the shape you set will be enforced, and the tensor will be a valid initial_value.

提交回复
热议问题