tensorflow API翻译

英文API看了真是不爽,翻译几个常用的API,不一定准确

Shape

Shape可以说是张量、或者说是向量

clipboard.png

可以以下图来表示的更加直观一点

clipboard.png

placeholder

占位符,用来定义变量
tf.placeholder(dtype, shape=None, name=None)
shape是变量的维数,name是用来定义保存的变量名
x = tf.placeholder(tf.float32, shape=(1024, 1024))
定义了一个一维的,1024x1024的变量,不可直接使用,必须先初始化

x = tf.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)

with tf.Session() as sess:
  print(sess.run(y))  # ERROR: will fail because x was not fed.

  rand_array = np.random.rand(1024, 1024)
  print(sess.run(y, feed_dict={x: rand_array}))  # Will succeed.

truncated_normal

tf.truncated_normal(shape, mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)
使用正态分布输出到shape,shape就是tensorflow中定义的“形状了”,在这里是一个一维的Array和Tensorflow数组

clipboard.png

代码示例

weights = tf.Variable(tf.truncated_normal((120, 5)))
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(tf.truncated_normal((120, 5))))

可是生成出来是个二维的?输出结果:

clipboard.png

argmax(input, axis=None, name=None, dimension=None)

返回指定维度上最大值的index
axis:维度
比如当前维度为[1,2,6,3],那么返回6的index:2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值