神经网络可以逼近任何函数的视觉证明

时间:2017-11-27 10:02:01

标签: machine-learning neural-network keras

我想创建一个完全适合我的样本的神经网络,但是在某些时候学习过程会停止。像adam或sgd这样的不同优化器也不起作用。

Cybenko证明了标题中的声明对于任何sigmoidal函数都是正确的,因为我想使用sigmoid或tanh。我还想保留一个隐藏层。

我可以使用哪些调整?这是我的设置(python3)和结果:

features = np.linspace(-0.5,.5,2000).reshape(2000,1)
target = np.sin(12*features)

hn = 100 
nn = models.Sequential()

#Only one hidden layer
nn.add(layers.Dense(units=hn, activation='sigmoid', 
                              input_shape=(features.shape[1],)))
nn.add(layers.Dense(units=1, activation='linear'))

# Compile neural network
nn.compile(loss='mse', 
           optimizer='RMSprop', 
           metrics=['mse']) 

nn.fit(features, 
       target, 
       epochs=200, 
       verbose=2, 
       batch_size=5) 

dark blue - target, blue - prediction

0 个答案:

没有答案