2018-04-01TensorFlow初步,神经网络的一层

2018-04-01  本文已影响0人  DIO哒
import tensorflow as tf

def add_layer(inputs,in_size,out_size,activation_function=None):
    Weights = tf.Variable(tf.random_normal([in_size,out_size]))#row * col
    biases=tf.Variable(tf.zeros([1,out_size])+0.1)
    Wx_plus_b=tf.matmul(inputs,Weights)+biases
    if activation_function is None:
        outputs=Wx_plus_b
    else :
        outputs=activation_function(Wx_plus_b)
    return outputs

图示的话大概是下面这样


image.png
上一篇下一篇

猜你喜欢

热点阅读