TensorFlow学习笔记(八)add_layer操作

这里只是给神经网络定义一个函数,目的是添加一层网络

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]))
    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


返回值为output。

你可能感兴趣的:(TensorFlow,Tensorflow学习笔记)