吴裕雄--天生自然TensorFlow2教程:数学运算
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教程:数学运算的更多相关文章
- 吴裕雄--天生自然TensorFlow2教程:手写数字问题实战
import tensorflow as tf from tensorflow import keras from keras import Sequential,datasets, layers, ...
- 吴裕雄--天生自然TensorFlow2教程:函数优化实战
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def himme ...
- 吴裕雄--天生自然TensorFlow2教程:反向传播算法
- 吴裕雄--天生自然TensorFlow2教程:链式法则
import tensorflow as tf x = tf.constant(1.) w1 = tf.constant(2.) b1 = tf.constant(1.) w2 = tf.consta ...
- 吴裕雄--天生自然TensorFlow2教程:多输出感知机及其梯度
import tensorflow as tf x = tf.random.normal([2, 4]) w = tf.random.normal([4, 3]) b = tf.zeros([3]) ...
- 吴裕雄--天生自然TensorFlow2教程:单输出感知机及其梯度
import tensorflow as tf x = tf.random.normal([1, 3]) w = tf.ones([3, 1]) b = tf.ones([1]) y = tf.con ...
- 吴裕雄--天生自然TensorFlow2教程:损失函数及其梯度
import tensorflow as tf x = tf.random.normal([2, 4]) w = tf.random.normal([4, 3]) b = tf.zeros([3]) ...
- 吴裕雄--天生自然TensorFlow2教程:激活函数及其梯度
import tensorflow as tf a = tf.linspace(-10., 10., 10) a with tf.GradientTape() as tape: tape.watch( ...
- 吴裕雄--天生自然TensorFlow2教程:梯度下降简介
import tensorflow as tf w = tf.constant(1.) x = tf.constant(2.) y = x * w with tf.GradientTape() as ...
随机推荐
- 嵊州普及Day1T2
题意:走迷宫.求走到a[n][n]需要多久. 考场上想的dfs,听老师说最多50分.代码懒得码了,知道是走迷宫就好. 正解:bfs,时间复杂度O(n). 见代码: #include<iostre ...
- memortstream Base64编码和filestream base64编码不同
memorystream base64 function BaseImage(fn: string): string; var m1: TMemoryStream; m2: TStringSt ...
- 七、Vue组件库:Element、Swiper(轮播专用组件)
一.vue的Element组件库 官网:https://element.eleme.cn/#/zh-CN 1.1安装 推荐安装方法: 首先要进入项目目录 cnpm i element-ui -S 或 ...
- Linux: 桥接 NET HOST-only
桥接 虚拟机会利用真实的网卡和真实计算机之间通信 还能和同一局域网之间的计算机之间通信 缺点:会耗费一个ip地址 NET:虚拟机会通过VMnet8 虚拟的网卡与真实计算机之间通信 如果真实计可 ...
- tab选项卡,不带自动切换定时器
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content ...
- maven启动报错No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building th ...
- SQL语句中为什么要用 where 1=1
where 1=1; 这个条件始终为True,在不定数量查询条件情况下,1=1可以很方便的规范语句,1=1 是永恒成立的,意思无条件的,也就是说在SQL语句中有没有这个1=1都可以. 如:web界面查 ...
- LINUX——磁盘管理
硬盘种类 SATA硬盘:用SATA接口的硬盘又叫串口硬盘,是以后PC机的主流发展方向,因为其有较强的纠错能力,错误一经发现能自动纠正,这样就大大的提高了数据传输的安全性.新的SATA 使用了差动信号系 ...
- ROS大型工程学习(一) 必须了解的基本文件
一.Cmake文件 阅读工程,首先点开CMakeLists 文件,会定义一些库和可执行文件.首先看可执行文件,rosrun的就是这个节点navigator add_executable(navigat ...
- Vulkan 之 Layers
Layers 暴露给api层,不像传统图形API集成在驱动里面,开发者根据自己的需要进行开启,最终目的还是为了提高性能. The Loader he loader is the central arb ...