GRNN 使用 neupy

GRNN using neupy

我正在尝试了解如何使用 Neupy. The problem is that I cant seem to find much options for a GRNN, only the sigma value as described here 配置神经网络:

有一个参数,y_i,我希望能够调整,但似乎没有办法在包装上做到这一点。我正在解析代码,但我不是开发人员,所以我在执行所有步骤时遇到了麻烦,也许更有经验的人可以找到调整该参数的方法。

谢谢

从您提供的 link 看来,y_i 是目标变量。在您的情况下,这是您的目标训练变量。在 neupy 代码中,它在预测期间使用。 https://github.com/itdxer/neupy/blob/master/neupy/algorithms/rbfn/grnn.py#L140

GRNN 使用懒惰学习,这意味着它不训练,它只是 re-uses 每个预测的所有训练数据。 self.target_train 变量只是您在训练阶段使用的一个副本。您可以在进行预测之前更新此值

from neupy import algorithms

grnn = algorithms.GRNN(std=0.1)
grnn.train(x_train, y_train)

grnn.train_target = modify_grnn_algorithm(grnn.train_target)
predicted = grnn.predict(x_test)

或者您可以使用 GRNN 代码代替默认的 predict 函数进行预测

import numpy as np
from neupy import algorithms
from neupy.algorithms.rbfn.utils import pdf_between_data

grnn = algorithms.GRNN(std=0.1)
grnn.train(x_train, y_train)

# In this part of the code you can do any moifications you want
ratios = pdf_between_data(grnn.input_train, x_test, grnn.std)
predicted = (np.dot(grnn.target_train.T, ratios) / ratios.sum(axis=0)).T