将一个numpy数据转换为tensor:
- x = np.array([[1,1],[2,2]])
- tx = tf.convert_to_tensor(x)
- tx:array([[1,1],
- [2,2]])
nest.flatten的作用:
- from tensorflow.python.util import nest
- ty = tx
- tuplee = (tx,ty)
- fla = nest.flatten(tuplee)
对数组进行flatten后,fla为一个列表,其元素为tx,ty,而对列表进行flatten后,返回的结果是其所有元素的展开,注意区别.如下:
- m = [[1,1],[2,2]]
- n = m
- d = (m,n)
- o = nest.flatten(d)
- o:[1,1,2,2,1,1,2,2]
评论记录:
回复评论: