莫烦 Tensorflow 添加层

import  tensorflow as tf
def add_layer(intput,insize,outsize,activative):
    Weight=tf.Variable(tf.random_normal([insize,outsize]))#输入的值是行向量(1*n维)输出是1*m
    Biase=tf.Variable(tf.zeros([1,outsize])+0.1)#设置baise的值全为0.1
    Wx_plus_b=tf.matmul(input,Weight)+Biase
    if activative is None:
        outputs=Wx_plus_b
    else:
        outputs=activative(Wx_plus_b)
    return outputs

你可能感兴趣的:(TensorFlow)