吴裕雄--天生自然TensorFlow2教程:误差计算

import tensorflow as tf y = tf.constant([1, 2, 3, 0, 2])
y = tf.one_hot(y, depth=4) # max_label=3种
y = tf.cast(y, dtype=tf.float32) out = tf.random.normal([5, 4])
out
loss1 = tf.reduce_mean(tf.square(y - out))
loss1
loss2 = tf.square(tf.norm(y - out)) / (5 * 4)
loss2
loss3 = tf.reduce_mean(tf.losses.MSE(y, out))
loss3

a = tf.fill([4], 0.25)
a * tf.math.log(a) / tf.math.log(2.)
-tf.reduce_sum(a * tf.math.log(a) / tf.math.log(2.))
a = tf.constant([0.1, 0.1, 0.1, 0.7])
-tf.reduce_sum(a * tf.math.log(a) / tf.math.log(2.))
a = tf.constant([0.01, 0.01, 0.01, 0.97])
-tf.reduce_sum(a * tf.math.log(a) / tf.math.log(2.))




tf.losses.categorical_crossentropy([0, 1, 0, 0], [0.25, 0.25, 0.25, 0.25])
tf.losses.categorical_crossentropy([0, 1, 0, 0], [0.1, 0.1, 0.8, 0.1])
tf.losses.categorical_crossentropy([0, 1, 0, 0], [0.1, 0.7, 0.1, 0.1])
tf.losses.categorical_crossentropy([0, 1, 0, 0], [0.01, 0.97, 0.01, 0.01])
tf.losses.BinaryCrossentropy()([1],[0.1])
tf.losses.binary_crossentropy([1],[0.1])
吴裕雄--天生自然TensorFlow2教程:误差计算的更多相关文章
- 吴裕雄--天生自然TensorFlow2教程:前向传播(张量)- 实战
手写数字识别流程 MNIST手写数字集7000*10张图片 60k张图片训练,10k张图片测试 每张图片是28*28,如果是彩色图片是28*28*3-255表示图片的灰度值,0表示纯白,255表示纯黑 ...
- 吴裕雄--天生自然TensorFlow2教程:创建Tensor
import numpy as np import tensorflow as tf tf.convert_to_tensor(np.ones([2, 3])) tf.convert_to_tenso ...
- 吴裕雄--天生自然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]) ...
随机推荐
- Linux - Shell - date
概述 date 命令 准备 OS CentOS 7.6 基本功能 显示时间 格式化时间 翻译时间 转换时间格式 切换时区 设置时间 查看文件最后使用时间 1. 显示时间 概述 基本功能 命令 # 内容 ...
- dk7和jdk8的一些新特性
本文是我学习了解了j 的一些资料,有兴趣的大家可以浏览下下面的内容. 官方文档:http://www.oracle.com/technetwork/java/javase/jdk7-relnotes- ...
- Java:反射机制学习笔记
目录 一.反射机制 1.概述 2.优缺点 3.类加载的过程 二.获取Class对象的三种方式 1.Class.forName("全类名") 2.类名.class 3.对象.getC ...
- openresty-component
1.Array Var Nginx Module ArrayVarNginxModulelocation /foo { array_split ',' $arg_files to=$array; # ...
- handler method 参数绑定
handler method 参数绑定常用的注解,我们根据他们处理的Request的不同内容部分分为四类:(主要讲解常用类型) A.处理requet uri 部分(这里指uri template中va ...
- https://www.cnblogs.com/lfs2640666960/p/8529115.html
https://www.cnblogs.com/lfs2640666960/p/8529115.html
- C语言-对字符串二维数组各个元素进行比较-十进制数转化为其他进制数-进行规则矩阵的输出-190225
//编写一个函数:从传入的num个字符中找到最长的一个字符,并通过max传回该串地址. //重点:切记这里a[0]就是一个地址. #include<conio.h> #include< ...
- CodeBlocks17.12配置GNU GCC + 汉化
Codeblocks17.12以及Gcc和汉化包链接: 链接:https://pan.baidu.com/s/1F23fjvi8xRpQ9xR14ILpEA 提取码:90d6 一.TDM-GCC 的安 ...
- 解决安装 fireworks、photoshop 时卡在输入账号、手机号处等问题
一定要断网! 一定要断网! 一定要断网! 重要的事情说三遍! 我安装的是破解版CS6系列: 安装步骤如下: 1.当进行安装到此步时,(前面的步骤为解压文件等便不解释),选择“试用”,此时应该是 断网 ...
- git warning: CRLF will be replaced by LF in resources/views/sessions/create.blade.php
git config core.autocrlf false