tensorflow学习笔记

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

池化

tf.nn.max_pool(value, ksize, strides, padding, data_format='NHWC', name=None)

Performs the max pooling on the input.

Args:
  • value: A 4-D Tensor with shape [batch, height, width, channels] and
    type tf.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 here
  • data_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()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值