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. 【 SSH 实例】使用ssh开发的简单项目

    简单的员工管理项目,使用spring.struts1.hibernate开发 applicationContext.xml <?xml version="1.0" encod ...

  2. 【 SSH 整合】Spring、Struts、Hibernate基本整合

    applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xm ...

  3. 【PAT甲级】1108 Finding Average (20分)

    题意: 输入一个正整数N(<=100),接着输入一行N组字符串,表示一个数字,如果这个数字大于1000或者小于1000或者小数点后超过两位或者压根不是数字均为非法,计算合法数字的平均数. tri ...

  4. ALSA driver--PCM Interrupt handle

    PCM 中断处理函数的主要作用是用来更新buffer position. 在PCM的interrupt handle里面通过snd_pcm_period_elapsed来通知alsa-core buf ...

  5. 对于使用secureFX上传文件到centos7 的时候,以及不同的用户解压文件,对于文件操作权限的实验

    本以为以一个用户胡如root登录了SecureFx,之后选择了root的家目录下的一个software目录,之后上传 以root用户远程登录LINUX系统 查看文件 之后再验证普通用户zhaijh登录 ...

  6. 吴裕雄 python 神经网络——TensorFlow实现搭建基础神经网络

    import numpy as np import tensorflow as tf import matplotlib.pyplot as plt def add_layer(inputs, in_ ...

  7. appium 无法通过工具定位webview页面元素的问题

    app里面页面有原生和webview的,或者H5的 1.手机百度搜索结果页面 手机百度,点击搜索输入框,输入关键字点击搜索,出来的搜索结果页面,无法通过UI automator viewer来定位元素 ...

  8. java文件上传判断文件夹是否存在

    判断文件夹是否存在,不存在创建文件夹 File file =new File("E:/workspace/net/src/main/webapp/upload"); //如果文件夹 ...

  9. codeforces-Three Friends

      Three Friends Three friends are going to meet each other. Initially, the first friend stays at the ...

  10. 具体的client-server通信模型以及最为常用的通信模式

    实现虚拟网络服务的主要技术,指出IP负载均衡技术是在负载调度器的实现技术中效率最高的. 在已有的IP负载均衡技术中: 1)有通过网络地址转换(Network Address Translation)将 ...