var.name 和 var.op.name
opt = tf.train.GradientDescentOptimizer(1e-4)
grads_and_vars = opt.compute_gradients(total_loss)
for grad, var in grads_and_vars:
print(var.op.name)
the output is: conv1/filt conv1/bias
and when I change var.op.name into var.name
the output is: conv1/filt:0 conv1/bias:0
var.op.name是指每个变量在创立时的操作的名字,也即为变量申请内存时的那个操作的名字。而var.name是Tensor名字,Tensor是操作的输出,也就是在创立变量的这个操作的输出就是所创立的变量。
tf.read_file 和 tf.image.decode_jpeg
tensor_queue=tf.train.slice_producer([paths],)
#返回的per_path是包含名字的tensor
per_path=tensor_queue[0]
#可以输出per_path看到是['/home/user/1.jpg']
per_path=tf.Print(per_path,[per_path],message='')
raw_input,=tf.py_func(cv_imread,[per_path],[tf.uint8])
#py_func输出没有shape
raw_input.set_shape((300,300,3))
tf.image
tf.image.random_brightness(img,0.5) 表示像素加减0.5。然后clip成[0,1)。
tf.image.adjust_brightness(img,0.5)表示加0.5,然后clip
tf.image.random_contrast(img,0.1,5)表示gamma校正中的gamma值在0.1-5之间选择。当gamma=1时,
图像保持不变。