小编jks*_*hin的帖子

ValueError:必须完全定义所有形状.由于评论tf.random_crop而导致的问题

这个问题在某种程度上是一个扩展我如何使用从TFRecords读取的值作为tf.reshape的参数?

我使用以下代码将图像转换为特定形状:

height = tf.cast(features['height'],tf.int32)
width = tf.cast(features['width'],tf.int32)
image = tf.reshape(image,tf.pack([height, width, 3]))
Run Code Online (Sandbox Code Playgroud)

在cifar10_input代码中,图像随后被扭曲,其中IMAGE_SIZE = 32:

height = IMAGE_SIZE
width = IMAGE_SIZE
distorted_image = tf.random_crop(image, [height, width, 3])
Run Code Online (Sandbox Code Playgroud)

但是,就我的目的而言,我现在不需要随机播种.因此,我用以下内容替换了该行:

distorted_image = image
Run Code Online (Sandbox Code Playgroud)

当我这样做时,它会抛出以下错误:

Traceback (most recent call last):
  File "cnn_train.py", line 128, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/default/_app.py", line 30, in run
    sys.exit(main(sys.argv))
  File "cnn_train.py", line 124, in main
    train()
  File "cnn_train.py", line 56, in train
    images, labels = cnn.distorted_inputs()
  File "/home/samuelchin/tensorflow/my_code/CNN/cnn.py", line 123, in distorted_inputs
    batch_size=BATCH_SIZE)
  File "/home/samuelchin/tensorflow/my_code/CNN/cnn_input.py", line …
Run Code Online (Sandbox Code Playgroud)

tensorflow

4
推荐指数
1
解决办法
5738
查看次数

无法使用bazel从源代码构建TensorFlow.2016年1月22日

我想从源代码安装最新的TensorFlow.我拉了存储库,然后跑了

bazel build -c opt //tensorflow/tools/pip_package:build_pip_package

我收到了这个错误:

ERROR: /home/samuelchin/tensorflow/tensorflow/models/embedding/BUILD:10:6: First argument of load() is a path, not a label. It should start with a single slash if it is an absolute path.
ERROR: /home/samuelchin/tensorflow/tensorflow/models/embedding/BUILD:10:6: file '/tensorflow:tensorflow.bzl.bzl' was not correctly loaded. Make sure the 'load' statement appears in the global scope in your file.
ERROR: /home/samuelchin/tensorflow/tensorflow/models/embedding/BUILD:104:1: name 'tf_gen_op_wrapper_py' is not defined.
ERROR: /home/samuelchin/tensorflow/tensorflow/tools/pip_package/BUILD:13:1: Target '//tensorflow/models/embedding:package' contains an error and its package is in error and referenced by '//tensorflow/tools/pip_package:build_pip_package'.
ERROR: Loading failed; …
Run Code Online (Sandbox Code Playgroud)

bazel tensorflow

3
推荐指数
1
解决办法
2176
查看次数

我们如何使用tf.image.encode_jpeg在TensorFlow中写出图像?

给定张量,我想使用此函数获取0D字符串,然后将其写为“ sample.jpg”。

这可以通过OpenCV或Python PIL轻松实现,但我希望尽可能将所有内容保留在TF中。

tensorflow

2
推荐指数
1
解决办法
5067
查看次数

使用图像裁剪作为训练数据集的 TensorFlow 对象检测 API

我想从 Tensorflow 对象检测 API 训练一个 ssd-inception-v2 模型。我想使用的训练数据集是一堆不同大小的裁剪图像,没有边界框,因为裁剪本身就是边界框。

我按照 create_pascal_tf_record.py 示例相应地替换了边界框和分类部分以生成 TFRecords,如下所示:

def dict_to_tf_example(imagepath, label):
    image = Image.open(imagepath)
    if image.format != 'JPEG':
         print("Skipping file: " + imagepath)
         return
    img = np.array(image)
    with tf.gfile.GFile(imagepath, 'rb') as fid:
        encoded_jpg = fid.read()
    # The reason to store image sizes was demonstrated
    # in the previous example -- we have to know sizes
    # of images to later read raw serialized string,
    # convert to 1d array and convert to respective
    # shape that image …
Run Code Online (Sandbox Code Playgroud)

image-processing computer-vision deep-learning conv-neural-network tensorflow

0
推荐指数
1
解决办法
1626
查看次数