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

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

你可能感兴趣的:(2018-04-01TensorFlow初步,神经网络的一层)