1 Star 1 Fork 1

海之号角/TensorFlowDemo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tf_demo06_define_addLayer_for_demo11.py 1010 Bytes
一键复制 编辑 原始数据 按行查看 历史
海之号角 提交于 2016-12-11 09:56 +08:00 . 提交项目文件
# coding:utf-8
"""
tf_demo06_define_addLayer_for_demo11
Created on 2016/12/9 16:27
@author: GuoYufu
@group : OceanHorn
@contact: OceanHorn@163.com
"""
import tensorflow as tf
def add_layer(inputs, in_size, out_size, n_layer, activation_function=None):
layer_name = 'layer%s' % n_layer
with tf.name_scope('weights'):
weights = tf.Variable(
initial_value=tf.random_normal(shape=[in_size, out_size])
)
tf.histogram_summary(tag=layer_name + '/weights', values=weights)
with tf.name_scope('biases'):
biases = tf.Variable(
tf.zeros([1, out_size]) + 0.1
)
tf.histogram_summary(tag=layer_name + '/biases', values=biases)
with tf.name_scope('layer_output'):
wx_plus_b = tf.matmul(inputs, weights) + biases
if activation_function is None:
outputs = wx_plus_b
else:
outputs = activation_function(wx_plus_b)
tf.histogram_summary(tag=layer_name + '/outputs', values=outputs)
return outputs
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/OceanHorn/TensorFlowDemo.git
git@gitee.com:OceanHorn/TensorFlowDemo.git
OceanHorn
TensorFlowDemo
TensorFlowDemo
master

搜索帮助