sigmoid

out' = sigmoid(out) # 把输出值压缩在0-1

import tensorflow as tf
a = tf.linspace(-6., 6, 10)
a
tf.sigmoid(a)
x = tf.random.normal([1, 28, 28]) * 5
tf.reduce_min(x), tf.reduce_max(x) x = tf.sigmoid(x)
tf.reduce_min(x), tf.reduce_max(x)
a = tf.linspace(-2., 2, 5)
tf.sigmoid(a) # 输出值的和不为1
softmax
tf.nn.softmax(a) # 输出值的和为1

logits = tf.random.uniform([1, 10], minval=-2, maxval=2)
logits
prob = tf.nn.softmax(logits, axis=1)
prob
tf.reduce_sum(prob, axis=1)

tf.tanh(a)

吴裕雄--天生自然TensorFlow2教程:输出方式的更多相关文章

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

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

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

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

  3. 吴裕雄--天生自然TensorFlow2教程:前向传播(张量)- 实战

    手写数字识别流程 MNIST手写数字集7000*10张图片 60k张图片训练,10k张图片测试 每张图片是28*28,如果是彩色图片是28*28*3-255表示图片的灰度值,0表示纯白,255表示纯黑 ...

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

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

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

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

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

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

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

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

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

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

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

随机推荐

  1. 【游戏体验】Buttonhunt(鼠标寻找按钮)

    虽然画风千奇百变 但这款益智游戏的趣味性相当高 推荐试玩 个人测评 游戏性 9/10 音乐 4/10 剧情 6/10 总评 19/30

  2. hadoop学习笔记(七):hadoop2.x的高可用HA(high avaliable)和联邦F(Federation)

    Hadoop介绍——HA与联邦 0.1682019.06.04 13:30:55字数 820阅读 138 Hadoop 1.0中HDFS和MapReduce在高可用.扩展性等方面存在问题: –HDFS ...

  3. pwnable.kr-random-Writeup

    MarkdownPad Document *:first-child { margin-top: 0 !important; } body>*:last-child { margin-botto ...

  4. redis-start

    start CAP BASE: 基本可用 Basically Available 软状态 Soft state 最终一致 Eventually consistent Redis:REmote DIct ...

  5. 本次我们使用idea构建springmvc项目

    该案例的github地址:https://github.com/zhouyanger/demo/tree/master/springmvcdemo1 1.首先我们可以创建maven项目,file-&g ...

  6. Plastic Sprayers Manufacturer -Plastic Spray Bottle Product Features, Nozzle Properties

    Nowadays, plastic spray bottles are widely used in the plastic packaging industry. What are the char ...

  7. re模块、正则表达式

    一.正则表达式 1.正则表达式不是Python独有的,它是一门独立的技术,所有的编程语言都可以使用正则表达式,在Python中使用正则表达式就要借助于re模块,或者是支持正则表达式书写的方法. 2.用 ...

  8. 如何利用wx.request进行post请求

    1,method 是  get  方式的时候,会将数据转换成 query string method 为 post 时,header为{"Content-Type": " ...

  9. NIO的理解

    一.缓冲区(Buffer):在java NIO中负责数据的存取,实际上就是数组,用于存储不用数据类型的数据,根据数据类型不同(boolean除外),提供了相应类型的缓冲区(ByteBuffer,Cha ...

  10. Java面向对象内存图

    1. java虚拟机的内存划分 2. 苹果手机类 package cn.itcast.day06.demo02; /* 定义一个类,用来模拟“手机”事物. 属性:品牌.价格.颜色 行为:打电话.发短信 ...