constants操作

import tensorflow as tf
a = tf.constant([2, 2], name='a')
b = tf.constant([[0, 1], [2, 3]], name='b')
x = tf.multiply(a, b, name='mul')
with tf.Session() as sess:
print(sess.run(x))
# >> [[0 2]
# [4 6]]
# 普通的元素数乘
常见 返回值类型 参数 说明
算数运算符
.add() Tensor x, y, name=N 加法(若x,y都为tensor, 数据类型需一致, 以下所有x,y都如此)
.subtract() Tensor 同add 减法
.multiply() Tensor 同add 元素级乘法
.scalar_mul() Tensor scalar, x 标量*tensor
.div() Tensor 同add 除法(结果dtype同x,y)
.divide() Tensor 同add 同Python除法 int8, int16 --> float32  int32, int64 --> float64
.truediv() Tensor 同add 同上
.floordiv() Tensor 同add 结果向下取整, 但结果dtype与输入保持一致
.realdiv() Tensor 同add 貌似仅支持浮点型除法
.truncatediv() Tensor 同add 结果截取整数部分, 貌似仅支持整数除法
.floor_div() Tensor 同add 没发现跟floordiv有什么不同
.truncatemod() Tensor 同add 取余, 跟truncatediv对应的取余
.floormod() Tensor 同add 取余, 跟floordiv对应的取余
.mod() Tensor 同add .floormod别名
.cross() Tensor a, b, name=N sum(a*out) = sum(b*out) = 0
基本数学函数(以下name参数全部省略)
.add_n() Tensor inputs list: [Tensor], 计算列表中所有tensor的加法运算
.abs() Tensor x 求绝对值
.negative() Tensor x 负, -x
.sign() Tensor x 符号, y = -1 if x < 0; 0 if x == 0 or tf.is_nan(x); 1 if x > 0
.reciprocal() Tensor x 倒数, 1/x
.square() Tensor x 平方, x**x
.round() Tensor x 四舍六入, 五取偶
.sqrt() Tensor x 开方, x**0.5
.rsqrt() Tensor x 开方的倒数, 1/x**0.5
.pow() Tensor x, y x**y
.exp() Tensor x e**x
.expm1() Tensor x e**x - 1
.log() Tensor x logx
.log1p() Tensor x log(1 + x)
.ceil Tensor x 向上取整
.floor() Tensor x 向下取整
.maximum() Tensor x, y 取x,y中的同位置最大值
.minimum() Tensor x, y 取x,y中的同位置最小值
.cos() Tensor x 余弦
.sin() Tensor x 正弦
.lbeta() Tensor x ???
.tan() Tensor x

正切

CS20Chapter2的更多相关文章

随机推荐

  1. 中南月赛F ZZY and his little friends

    Problem F: ZZY and his little friends Time Limit: 5 Sec  Memory Limit: 256 MBSubmit: 137  Solved: 70 ...

  2. java语言的各种输入情况(ACM常用)

    1.只输入一组数据: Scanner s=new Scanner(System.in); int a=s.nextInt(); int b=s.nextInt(); 2.输入有多组数据,没有说明输入几 ...

  3. Luogu3804:[模板]后缀自动机

    题面 luogu Sol \(sam\)然后树形\(DP\) 当时还不会拓扑排序的我 # include <bits/stdc++.h> # define IL inline # defi ...

  4. js判断pc端和移动端的方法

    function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", " ...

  5. 利用Metaweblog技术的API接口同步到多个博客网站(详细)

    很早就有这个想法:自己有时候会用到多个博客,有些博客在一个网站上写完之后,要同步到其他博客网站,自己只能复制粘贴,感觉特别没意思,复制粘贴的麻木了.一直在想有哪些技术能实现一次写博,多站同步.最近网上 ...

  6. LeetCode 533----Lonely Pixel II

    问题描述 Given a picture consisting of black and white pixels, and a positive integer N, find the number ...

  7. 学习servlet心得

    1,关于字符编码问题: // resp.setCharacterEncoding("UTF-8");//这个的作用仅仅只是输出字符,不做格式转换成HTML // resp.setC ...

  8. zTree 学习笔记之(一)

    zTree 学习笔记之(一) 简介 zTree 是一个依靠 jQuery 实现的多功能 “树插件”.优异的性能.灵活的配置.多种功能的组合是 zTree 最大优点. 到底有哪些具体的优点,可以参见官网 ...

  9. Jarvis OJ-Reverse题目Writeup

    做一道更一道吧233333 DD-Android Easy 下载apk,先安装一下试试吧…… 猜测是输入正确的内容后给flag吧 将后缀改成zip,解压,用dex2jar处理classes.dex,然 ...

  10. python item repr doc format slots doc module class 析构 call 描述符

    1.item # __getitem__ __setitem__ __delitem__ obj['属性']操作触发 class Foo: def __getitem__(self, item): r ...