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. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-music

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

  2. SSH和SFTP的简单使用

    ssh命令 ssh 命令用来远程登录linux主机:ssh username@hostname 默认端口是22,如果设定了其他端口,那么使用-p参数来指明,例如端口若改为6666, 则登录命令变为 s ...

  3. 实训30 延时中断组织块0B20仿真

    实训30 延时中断组织块的仿真试验   问题1 系统功能块SFC中提供了一些查询中断状态字的指令,举例说明 例如 SF34 "QRY_DINT" 用来查询 "延时中断&q ...

  4. Gym 101158D(暴力)

    题意:给定两个长度为N的字符串,1<=N<=4000,求满足字符串1中的某个区间所有的字母种类和个数都与字符串2中的某个区间相同最长的区间长度. 分析: 1.预处理每个串字母个数的前缀和. ...

  5. mysql 免安装版后续操作

    在安装好mysql后,软件默认的root用户的密码为空. 1.进入mysql 2.创建数据库 3.创建表格 4.插入数据 5.显示数据库.表信息

  6. ffmpeg “inttypes.h”: No such file or directory

    编译过程:错误一:无法打开包括文件:“inttypes.h”: No such file or directory解决方法:删除之,并在其之前添加如下代码: #if defined(WIN32) &a ...

  7. html5游戏的横屏问题

    html5 API有这个参数 Screen Orientation API 可以看w3c定义的规范 The Screen Orientation API <!-- UC强制竖屏 --> & ...

  8. Oracle 查询当前用户下的所有表

    select table_name from user_tables;

  9. 用25行JavaScript语句实现一个简单的编译器

    原文:https://www.iteye.com/news/32680 译者注:即使对于专业程序员来说,构造一个编译器也是颇具挑战性的任务,本文将会引导你抽丝剥茧,一探究竟! 我已经写了几篇与编程语言 ...

  10. Meeloun教你如何正式切入Essay写作话题

    很多同学在Essay写作过程中会发现:如果题目问到解决办法,写来写去,都是政府要颁布政策,人们要提高意识,感觉一点新意也没有.怎么样更好地切合不同的话题,想到最合适的解决办法呢?今天小编为你奉上更多处 ...