完整神经网络样例程序(TensorFlow)(源码)
TensorFlow实战Google深度学习框架案例P61-P64 源码如下: # coding=utf-8 """完整的神经网络解决二分类问题""" import tensorflow as tf from numpy.random import RandomState # 定义训练数据batch大小 batch_size = 8 # 定义神经网络的参数 w1 = tf.Variable(tf.random_normal([2, 3], stddev=1, seed=1)) w2 = tf.Variable(tf.random_normal([3, 1], stddev=1, seed=1)) # 在shape的一个维度上使用None可以方便使用不大的batch大小,在训练时需要把数据分 # 成比较小的batch,但是在测试时,可以一次性使用全部的数据。当数据集比较小时这样比较 # 方便测试,但数据集比价大时,将大量数据放入一个batch可能会导致内存溢出。 x = tf.placeholder(tf.float32, shape=(None, 2), name='x-input') y_ = tf.placeholder(tf.float32, shape=(None, 1), name='y-input') # 定义神经网络前向传播的过程 a = tf.matmul(x,