tensorflow操作
生成张量的函数
1. 常数
tf.constant(value, dtype=None, shape=None, name='Const', verify_shape=False)
tf.zeros(shape, dtype=tf.float32, name=None)
tf.ones(shape, dtype=tf.float43, name=None)
tf.zeros_like(input_tensor, dtype=None, name=None, optimize=None)
tf.ones_like(input_tensor, dtype=None, name=None, optimize=None)
tf.fill(dims, value, name=None)
tf.lin_space(start, stop, num, name=None)
tf.range(start, limit=None, delta=1, dtype=None, name='range')
随机产生常数:
tf.random_normal
tf.truncated_normal
tf.random_uniform
tf.random_shuffle
tf.random_crop
tf.multinomial
tf.random_gamma
tf.set_random_seed(seed)
2. 变量
https://blog.csdn.net/u012223913/article/details/78533910?locationNum=8&fps=1
tf.random_normal_initializer()
tf.truncated_normal_initializer()
tf.constant_initializer(0.0)
3. tf.layers
conv1 = tf.layers.conv2d(inputs=self.img, filters=32, kernel_size=[5,5], padding='SAME', activation=tf.nn.relu, name='conv1')
pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=[2,2], strides=2, name='pool1')
fc = tf.layers.dense(pool2, 1024, activation=tf.nn.relu, name='fc')
dropout = tf.layers.dropout(fc, self,keep_prob, training=self.training, name='dropout')