【发布时间】:2013-12-31 18:48:38
【问题描述】:
在一个项目上工作以使用 PyBrain 进行一些预测,但是我想知道如何以简单的方式限制 NN 输出的域,以便输出层仅在域 [0..1] 中生成值。
目前,我在网络的一些激活中得到负值。
我搜索了 PyBrain 文档,但没有遇到任何似乎表明这是可能的方法或方法参数。相关代码示例如下:
self.pybrain_net_date = buildNetwork(self.pb_indim, hidden_dim, hidden_dim, 1, hiddenclass=SigmoidLayer, outclass=LinearLayer, bias=True)
self.pybrain_net_amount = buildNetwork(self.pb_indim, hidden_dim, hidden_dim, 1, hiddenclass=SigmoidLayer, outclass=LinearLayer, bias=True)
trainer_date = BackpropTrainer(self.pybrain_net_date, self.pbds_train_date)
trainer_amount = BackpropTrainer(self.pybrain_net_amount, self.pbds_train_amount)
print trainer_date.trainUntilConvergence(self.pbds_train_date, 30, verbose=True, validationProportion=0.20)
print trainer_amount.trainUntilConvergence(self.pbds_train_amount, 30, verbose=True, validationProportion=0.20)
for index, row in input_dataframe.iterrows():
date = neuralnet_date.activate(row)
amount = neuralnet_amount.activate(row)
prediction_df['Expected Date'].ix[index] = date
prediction_df['Expected Amount'].ix[index] = amount
【问题讨论】:
标签: python-2.7 pybrain