~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
池化
tf.nn.max_pool(value, ksize, strides, padding, data_format='NHWC', name=None)
Performs the max pooling on the input.
Args:
value
: A 4-DTensor
with shape[batch, height, width, channels]
and
typetf.float32
.ksize
: A list of ints that has length >= 4. The size of the window for
each dimension of the input tensor.strides
: A list of ints that has length >= 4. The stride of the sliding
window for each dimension of the input tensor.padding
: A string, either'VALID'
or'SAME'
. The padding algorithm.
See the comment heredata_format
: A string. ‘NHWC’ and ‘NCHW’ are supported.name
: Optional name for the operation.
Returns:
A Tensor
with type tf.float32
. The max pooled output tensor.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 'x' is [[1., 2.]
# [3., 4.]]
tf.reduce_mean(x) ==> 2.5 #如果不指定第二个参数,那么就在所有的元素中取平均值 tf.reduce_mean(x, 0) ==> [2., 3.] #指定第二个参数为0,则第一维的元素取平均值,即每一列求平均值 tf.reduce_mean(x, 1) ==> [1.5, 3.5]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cast(x, dtype, name=None) 将x的数据格式转化成dtype.例如,原来x的数据格式是bool, 那么将其转化成float以后,就能够将其转化成0和1的序列。反之也可以
a = tf.Variable([1,0,0,1,1])
b = tf.cast(a,dtype=tf.bool)
sess = tf.Session()
sess.run(tf.initialize_all_variables())
print(sess.run(b))
#[ True False False True True]
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AttributeError: 'module' object has no attribute 'SummaryWriter'
tf.train.SummaryWriter
改为:tf.summary.FileWriter
AttributeError: 'module' object has no attribute 'summaries'
tf.merge_all_summaries()
改为:summary_op = tf.summary.merge_all()
AttributeError: 'module' object has no attribute 'histogram_summary'
tf.histogram_summary()
改为:tf.summary.histogram()
tf.scalar_summary()
改为:tf.summary.scalar()
tf.image_summary()
改为:tf.summary.image()