发新帖

tf.image.decode_png()返回的shape是问号

[复制链接]
292 1

快来加入 TensorFlowers 大家庭!

您需要 登录 才可以下载或查看,没有帐号?加入社区

x
本帖最后由 2h4dl 于 2019-4-1 11:10 编辑
img_raw = tf.read_file(ImagePath)
img_tensor = tf.cond(tf.image.is_jpeg(img_raw),
                     lambda: tf.image.decode_jpeg(img_raw),
                     lambda: tf.image.decode_png(img_raw))
print('shape:', img_tensor.shape)

[output]
shape: (?, ?, ?)



我看到官方的教程是可以输出shape的,哪位大佬指导一下。

官网示例

官网示例
我知道答案 回答被采纳将会获得10 金币 + 5 金币 已有1人回答
本楼点评(0) 收起

精彩评论1

2h4dl  TF荚荚  发表于 2019-4-1 10:56:32 | 显示全部楼层
本帖最后由 2h4dl 于 2019-4-1 11:10 编辑

在程序开头加上:
  1. tf.enable_eager_execution()
复制代码
就可以输出shape了。

eager_excution 可以直接运行op,而不需要事前建立graph,并且不需要创建session。
TensorFlow's eager execution is an imperative programming environment that evaluates operations immediately, without building graphs: operations return concrete values instead of constructing a computational graph to run later. This makes it easy to get started with TensorFlow and debug models, and it reduces boilerplate as well. To follow along with this guide, run the code samples below in an interactive python interpreter.

Eager execution is a flexible machine learning platform for research and experimentation, providing:

An intuitive interface—Structure your code naturally and use Python data structures. Quickly iterate on small models and small data.
Easier debugging—Call ops directly to inspect running models and test changes. Use standard Python debugging tools for immediate error reporting.
Natural control flow—Use Python control flow instead of graph control flow, simplifying the specification of dynamic models.
本楼点评(0) 收起
您需要登录后才可以回帖 登录 | 加入社区

本版积分规则

主题

帖子

17

积分
快速回复 返回顶部 返回列表