一、代码:
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
network_shape=[1,5,10,1]
learning_rate=0.1
display_step=500
num_steps=5000
x_dot=np.linspace(1,2,300,dtype=np.float32)[:,np.newaxis]
y_dot=2*np.power(x_dot,3)+np.power(x_dot,2)+np.random.normal(0,0.5,x_dot.shape)
X_p=tf.placeholder(dtype=tf.float32,shape=[None,network_shape[0]],name="input")
Y_p=tf.placeholder(dtype=tf.float32,shape=[None,network_shape[-1]],name="output")
w={"w1":tf.Variable(tf.random_normal([network_shape[0],network_shape[1]])),
"w2":tf.Variable(tf.random_normal([network_shape[1],network_shape[2]])),
"out":tf.Variable(tf.random_normal([network_shape[2],network_shape[3]]))}
b={"b1":tf.Variable(tf.random_normal([network_shape[1]])),
"b2": tf.Variable(tf.random_normal([network_shape[2]])),