1.transpose
tf.transpose(inputs, [0, 3, 1, 2])
原来inputs的维度[0, 1, 2, 3] ,经过上面就转换成[0, 3, 1, 2]了。
2.tf.pad
padded_inputs = tf.pad(inputs, [[0, 0], [0, 0],..)
‘t’ is [[1, 2, 3], [4, 5, 6]].
‘paddings’ is [[1, 1,], [2, 2]].
rank of ‘t’ is 2.
pad(t, paddings, “CONSTANT”) ==>
[[0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 2, 3, 0, 0],
[0, 0, 4, 5, 6, 0, 0],
[0, 0, 0, 0, 0, 0, 0]]
3.padding
转自http://blog.csdn.net/wuzqchom/article/details/74785643
当向右滑动两步之后“VALID”发现余下的窗口不到2x2所以就把第三列直接去了,而“SAME”并不会把多出的一列丢弃,但是只有一列了不够2x2怎么办?填充0!
4.FixedLengthRecordDataset
读cifar_10的二进制文件
https://blog.csdn.net/jyshee/article/details/52566152
tf.data.FixedLengthRecordDataset(filenames, record_bytes)#tf1.4
tf.contrib.data.FixedLengthRecordDataset(filenames, record_bytes)
tf.FixedLengthRecordReader.read(filenames, record_bytes)#tf1.3
下次调用时会接着上次读取的位置继续读取文件,而不会从头开始读取。record_bytes每张图片的大小。
5.tf.cast
就是转换格式
tf.cast(A, tf.int32)
将A转换成int32的格式。
6.tf.one_hot
https://blog.csdn.net/LoseInVain/article/details/78819390
将1,2,3,4,n,这种数字改成向量[0,0,1,0,,],只能在n的位置初现1.