tensorflow报错: Input to reshape is a tensor with 27648 values, but the requested shape has 13824 问题解决

    xiaoxiao2022-07-12  153

    在读取tfrecoders文件时出现错误:Input to reshape is a tensor with 27648 values, but the requested shape has 13824

     

     

     

    def read_and_decode(filename_queue): reader = tf.TFRecordReader() key, serialized_example = reader.read(filename_queue) features = tf.parse_single_example(serialized_example, features={'vol_raw': tf.FixedLenFeature([], tf.string)}) vol_str = tf.decode_raw(features['vol_raw'], tf.float32) #解析为float格式 volume = tf.reshape(vol_str, volume_shape) return volume

    检查数据大小是一致的,最后发现是在生成的tfrecoders文件原始数据的格式与解析函数tf.decode_raw的格式不同导致(代码如上),因此在生成tfrecoders文件时修改数据格式为float可解决问题

    参考链接:参考链接

    最新回复(0)