tf.train.batch(allow_smaller_final_batch = True,)不能正确地批量处理批处理

时间:2018-03-25 00:47:35

标签: tensorflow

如果我使用tf.train.batch( allow_smaller_final_batch=True, )张量的形状未知:

allow_smaller_final_batch=True:张量形状=(?,224,224,3) allow_smaller_final_batch=False:张量形状=(16,224,224,3)

这给了我下游的错误。

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/anaconda/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape)
    467     try:
--> 468       str_values = [compat.as_bytes(x) for x in proto_values]
    469     except TypeError:

/anaconda/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in <listcomp>(.0)
    467     try:
--> 468       str_values = [compat.as_bytes(x) for x in proto_values]
    469     except TypeError:

/anaconda/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/compat.py in as_bytes(bytes_or_text, encoding)
     64     raise TypeError('Expected binary or unicode string, got %r' %
---> 65                     (bytes_or_text,))
     66 

TypeError: Expected binary or unicode string, got None
...

TypeError: Failed to convert object of type <class 'list'> to Tensor. Contents: [None, 1]. Consider casting elements to a supported type.

在我评估batch_size之前如何获得session

1 个答案:

答案 0 :(得分:0)

batch_size是应该分配给它的超参数,而不是在TensorFlow会话中要评估的值,而没有足够的信息来确定遇到的麻烦。