【发布时间】:2017-06-30 10:22:11
【问题描述】:
我是张量流的新手 我尝试将 SVHN 数据集导入code that represented in this CNN tutorial 代码将 cifar10 数据集读取为二进制,我想将其替换为 SVHN 数据集作为 png 图像
我更改了图层和读取数据的步骤。此外,我在将所有输入图像读取为 [32,32] 后调整它们的大小
batch_size = 128
问题是当我尝试训练它时,它在输入数据步骤中给我一个错误::
子代码如下所示:::
label_bytes = 1 # 2 for CIFAR-100
result.height = 32
result.width = 32
result.depth = 3
image_bytes = result.height * result.width * result.depth
# Every record consists of a label followed by the image, with a
# fixed number of bytes for each.
record_bytes = label_bytes + image_bytes
# Read a record, getting filenames from the filename_queue. No
# header or footer in the CIFAR-10 format, so we leave header_bytes
# and footer_bytes at their default of 0.
reader = tf.WholeFileReader()
#for binar format (cifar daatset)
###reader = tf.FixedLengthRecordReader(record_bytes=record_bytes) ##using for binary (.bin) format
###reader = tf.TextLineReader() #this for scv formate and I used for .mat format
result.key, value = reader.read(filename_queue)
# Convert from a string to a vector of uint8 that is record_bytes long.
###record_bytes = tf.decode_raw(value, tf.uint8) ## for .bin formate
record_bytes = tf.image.decode_png(value)
result.uint8image = record_bytes
result.uint8image = tf.image.resize_images(result.uint8image, [32,32])
# The first bytes represent the label, which we convert from uint8->int32.
result.label = tf.cast(
tf.strided_slice(record_bytes, [0], [label_bytes]), tf.int32)
# The remaining bytes after the label represent the image, which we reshape
# from [depth * height * width] to [depth, height, width].
depth_major = tf.reshape(
tf.strided_slice(record_bytes, [label_bytes],
[label_bytes + image_bytes]),
[result.depth, result.height, result.width])
# Convert from [depth, height, width] to [height, width, depth].
result.uint8image = tf.transpose(depth_major, [1, 2, 0])
错误也显示在下面::
文件“/home/Desktop/SVHN/cifar10_input.py”,第 111 行,在 read_cifar10 中 [result.depth, result.height, result.width])
InvalidArgumentError(回溯见上文):reshape 的输入是具有 44856 个值的张量,但请求的形状具有 3072
我有两个问题::
1) 我想解释一下这个错误,因为我看不懂,我该如何解决。
2) 有什么好的教程可以解释如何选择一个好的 CNN 参数值
【问题讨论】:
标签: python tensorflow deep-learning