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])

最新文章

  1. 把普通对象转换成json格式的对象
  2. git乱码问题解决
  3. python-appium识别元素等待时间
  4. vs2012 MSDN帮助文档离线包下载安装方法
  5. diff和common
  6. CentOS 的网络配置
  7. Codeforces Round #189 (Div. 1) B. Psychos in a Line 单调队列
  8. JAVA将Excel中的报表导出为图片格式(一)问题背景
  9. 你不需要jQuery(四)
  10. BoundsChecker使用
  11. HDU 3480 DP+斜率优化
  12. 解决Android Device Chooser 找不到设备问题
  13. iOS制作毛玻璃效果
  14. 获取token之后,再调用匿名方法
  15. spring-session 共享
  16. IDEA配合Flash CS6开发Flash项目--配置篇
  17. Python12/11--盒子的显隐/布局/z-index/流式布局思想
  18. css组合选择器
  19. 清除win下连接的linux的samba服务缓存 用户名和密码
  20. Zookeeper 配置集群环境详解

热门文章

  1. python面向对象封装案例2
  2. LA 2995 立方体成像(模拟)
  3. java ArrayList添加元素全部一样
  4. Java面向对象编程 -6
  5. jq鼠标移入移除事件
  6. rsync+inotify实现主机之间目录实时同步
  7. 添加安卓端的User-Agent
  8. Google Earth Engine学习资源分享
  9. 序列变换 HDU - 5256
  10. spark实验(二)--scala实验(3)