import tensorflow as tf

b = tf.fill([2, 2], 2.)
a = tf.ones([2, 2])
a+b
a-b
a*b
a/b
b // a
b % a
tf.math.log(a)  # 只有以e为底的log
tf.exp(a)
tf.math.log(8.)/tf.math.log(2.)  # 以2为底
tf.math.log(100.)/tf.math.log(10.)  # 以10为底
tf.pow(b, 3)
b**3
tf.sqrt(b)
a@b
tf.matmul(a, b)
a = tf.ones([4, 2, 3])  # 4作为batch处理
b = tf.fill([4, 3, 5], 2.) # 4作为batch处理
a@b
tf.matmul(a, b)
bb = tf.broadcast_to(b, [4, 3, 5])
a@bb
x = tf.ones([4, 2])
W = tf.ones([2, 1])
b = tf.constant(0.1) # 自动broadcast为[4,1] x@W + b
out = x@W + b
tf.nn.relu(out)

吴裕雄--天生自然TensorFlow2教程:数学运算的更多相关文章

  1. 吴裕雄--天生自然TensorFlow2教程:手写数字问题实战

    import tensorflow as tf from tensorflow import keras from keras import Sequential,datasets, layers, ...

  2. 吴裕雄--天生自然TensorFlow2教程:函数优化实战

    import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def himme ...

  3. 吴裕雄--天生自然TensorFlow2教程:反向传播算法

  4. 吴裕雄--天生自然TensorFlow2教程:链式法则

    import tensorflow as tf x = tf.constant(1.) w1 = tf.constant(2.) b1 = tf.constant(1.) w2 = tf.consta ...

  5. 吴裕雄--天生自然TensorFlow2教程:多输出感知机及其梯度

    import tensorflow as tf x = tf.random.normal([2, 4]) w = tf.random.normal([4, 3]) b = tf.zeros([3]) ...

  6. 吴裕雄--天生自然TensorFlow2教程:单输出感知机及其梯度

    import tensorflow as tf x = tf.random.normal([1, 3]) w = tf.ones([3, 1]) b = tf.ones([1]) y = tf.con ...

  7. 吴裕雄--天生自然TensorFlow2教程:损失函数及其梯度

    import tensorflow as tf x = tf.random.normal([2, 4]) w = tf.random.normal([4, 3]) b = tf.zeros([3]) ...

  8. 吴裕雄--天生自然TensorFlow2教程:激活函数及其梯度

    import tensorflow as tf a = tf.linspace(-10., 10., 10) a with tf.GradientTape() as tape: tape.watch( ...

  9. 吴裕雄--天生自然TensorFlow2教程:梯度下降简介

    import tensorflow as tf w = tf.constant(1.) x = tf.constant(2.) y = x * w with tf.GradientTape() as ...

随机推荐

  1. 提升Windows系统舒适度软件

    1.Geek Uninstaller 卸载软件 2.PotPlayer 无广告播放器

  2. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):带有字体图标的导航栏

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  3. 使用Python绘制漫步图

    代码如下: import matplotlib.pyplot as plt from random import choice class RandomWalk(): def __init__(sel ...

  4. LeetCode1046 最后一块石头的重量(贪心—Java优先队列简单应用)

    题目: 有一堆石头,每块石头的重量都是正整数. 每一回合,从中选出两块最重的石头,然后将它们一起粉碎.假设石头的重量分别为 x 和 y,且 x <= y.那么粉碎的可能结果如下: 如果 x == ...

  5. 51nod 1208 && POJ 2482:Stars in Your Window

    1208 Stars in Your Window 题目来源: Poj 基准时间限制:2 秒 空间限制:131072 KB 分值: 160 难度:6级算法题  收藏  取消关注 整点上有N颗星星,每颗 ...

  6. python接口自动化26-发xml格式post请求《转载》

    python接口自动化26-发xml格式post请求 https://cloud.tencent.com/developer/article/1164987

  7. 128-PHP类继承extends

    <?php class father{ //定义father类 //定义public描述的成员属性和方法 public $eyes=2; public $ears=2; public funct ...

  8. 067-PHP使用匿名函数

    <?php $func=function ($x,$y){ //匿名函数与变量绑定 return $x+$y; }; echo '5+6='.$func(5,6); //使用匿名函数 echo ...

  9. HDU_4960 2014多校9 Another OCD Patient DP

    其实现在想起来是个巨简单的DP,模型就跟LCS很像,比赛的时候居然没想出来,在聪哥提醒下还卡了个地方 就是说给定一串n个数字的序列,可以连续合并,最终使得序列是回文的,题目也给定了合并数字所需的代价, ...

  10. 如何安装Anaconda

    如何安装Anaconda Python作为一门易读.易维护的语言,在工作和学习中应用广泛,被大量用户所欢迎.本文主要给大家介绍一下Anaconda 步骤 1 Anaconda在官网就可以下载,网址:h ...