TF中新的高阶函数在这里详述:
特别是,map函数看起来很有用。下面是他们为本教程编写的内容:
elems = [1, 2, 3, 4, 5, 6]
squares = map_fn(lambda x: x * x, elems)
# squares == [1, 4, 9, 16, 25, 36]因此,我创建了一个空python文件:
import tensorflow as tf
elems = [1, 2, 3, 4, 5, 6]
squares = tf.map_fn(lambda x: x * x, elems)运行此操作将产生以下错误:
/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.pyc in make_tensor_proto(values, dtype, shape)
323 else:
324 if values is None:
--> 325 raise ValueError("None values not supported.")
326 # if dtype is provided, forces numpy array to be the type
327 # provided if possible.
ValueError: None values not supported.有人知道这是怎么回事吗?谢谢!
编辑:我使用的是TensorFlow版本0.8。
发布于 2016-05-14 01:32:50
您的代码看起来不错,但是我可以使用numpy array来修复它,如下所示:
import tensorflow as tf
import numpy as np
elems = np.array([1, 2, 3, 4, 5, 6], dtype="float32")
squares = tf.map_fn(lambda x: x * x, elems)
sess = tf.Session()
sess.run(squares)这一产出如下:
[ 1. 4. 9. 16. 25. 36.]https://stackoverflow.com/questions/37221092
复制相似问题