Neural network Neurolab newff输出范围和来自网络的不同结果

Neural network Neurolab newff输出范围和来自网络的不同结果,neural-network,Neural Network,我意识到newff输出被固定在范围[-1,1]上,我执行以下操作来测试范围外的输出应该如何工作 import neurolab as nl import numpy as np # Create train samples x = np.linspace(-7, 7, 20) y = x * 10 size = len(x) inp = x.reshape(size,1) tar = y.reshape(size,1) norm_inp = nl.tool.Norm(inp) inp =

我意识到newff输出被固定在范围[-1,1]上,我执行以下操作来测试范围外的输出应该如何工作

import neurolab as nl
import numpy as np

# Create train samples
x = np.linspace(-7, 7, 20)
y = x * 10

size = len(x)

inp = x.reshape(size,1)
tar = y.reshape(size,1)

norm_inp = nl.tool.Norm(inp)
inp = norm_inp(inp)

norm_tar = nl.tool.Norm(tar)
tar = norm_tar(tar)

# Create network with 2 layers and random initialized
# as I normalized the inp, the input range is set to [0, 1] (BTW, I don't know how
#to norm it to [-1, 1])
net = nl.net.newff([[0, 1]],[5, 1])

# Train network
error = net.train(inp, tar, epochs=500, show=100, goal=0.02)

# Simulate network
out = norm_tar.renorm(net.sim([[ 0.21052632 ]]))

print "final output:-----------------"
print out

inp before norm
[[-7.        ]
 [-6.26315789]
 [-5.52631579]
 [-4.78947368]
 [-4.05263158]
 [-3.31578947]
 [-2.57894737]
 [-1.84210526]
 [-1.10526316]
 [-0.36842105]
 [ 0.36842105]
 [ 1.10526316]
 [ 1.84210526]
 [ 2.57894737]
 [ 3.31578947]
 [ 4.05263158]
 [ 4.78947368]
 [ 5.52631579]
 [ 6.26315789]
 [ 7.        ]]

tar before norm
[[-70.        ]
 [-62.63157895]
 [-55.26315789]
 [-47.89473684]
 [-40.52631579]
 [-33.15789474]
 [-25.78947368]
 [-18.42105263]
 [-11.05263158]
 [ -3.68421053]
 [  3.68421053]
 [ 11.05263158]
 [ 18.42105263]
 [ 25.78947368]
 [ 33.15789474]
 [ 40.52631579]
 [ 47.89473684]
 [ 55.26315789]
 [ 62.63157895]
 [ 70.        ]]
我预计输入0.21052632的输出在renorm之后大约为-40 但是结果是不可重复的,有时是正确的(大约-40),但有时是错误的(变成-70)


我想知道为什么训练结果不稳定,是否有更好的方法训练输出值超出范围[-1,1]

对于“newff”,有不同的训练方法。根据,您可以使用7种不同的列车功能。尽量使用不同的列车功能。是关于更改网络属性的示例。这是一个例子

import neurolab as nl
# Create 
net = nl.net.newff([[-1, 1]], [5, 1])
# Default train function (train_gdx) 
print net.trainf  # Trainer(TrainGDX)
# Change train function
net.trainf = nl.train.train_bfgs

虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面更改,仅链接的答案可能会无效。想想你@apaul34208,这是我第一次回答问题。我对它做了一些改变。