2019.2.25
tf.concat([tensor1, tensor2, tensor3,...], axis) #用来拼接张量
t1 = [[1, 2, 3], [4, 5, 6]]
t2 = [[7, 8, 9], [10, 11, 12]]
tf.concat([t1, t2], 0) # [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
tf.concat([t1, t2], 1) # [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]]
# tensor t3 with shape [2, 3]
# tensor t4 with shape [2, 3]
tf.shape(tf.concat([t3, t4], 0)) # [4, 3]
tf.shape(tf.concat([t3, t4], 1)) # [2, 6]
和np.concatenate()用法相同;
>>> a = np.array([[1, 2], [3, 4]])
>>> b = np.array([[5, 6]])
>>> np.concatenate((a, b), axis=0)
array([[1, 2],
[3, 4],
[5, 6]])
>>> np.concatenate((a, b.T), axis=1)
array([[1, 2, 5],
[3, 4, 6]])
2019.3.1
tf.InteractiveSession():它能让你在运行图的时候,插入一些计算图,这些计算图是由某些操作(operations)构成的。这对于工作在交互式环境中的人们来说非常便利,比如使用IPython。
tf.Session():需要在启动session之前构建整个计算图,然后启动该计算图。
意思就是在我们使用tf.InteractiveSession()来构建会话的时候,我们可以先构建一个session然后再定义操作(operation),如果我们使用tf.Session()来构建会话我们需要在会话构建之前定义好全部的操作(operation)然后再构建会话。
---------------------
作者:fool-zz
来源:CSDN
原文:https://blog.csdn.net/qq_14839543/article/details/77822916
版权声明:本文为博主原创文章,转载请附上博文链接!
2019.3.2
1.tf.reshape(tensor,shape,name=None)
import numpy as np
a=np.array([1,2,3,4,5,6,7,8])
output=a.reshape((2,4))
print(output)
结果为:[[1 2 3 4] [5 6 7 8]]
2.tf.name_scope和tf.variable_scope()的用法:主要用于共享变量,如下面的链接所示,不过没有看懂。。
https://www.imooc.com/article/22966