问题描述
我是神经网络的新手,我想尝试制作一个模型来猜测某个点相对于函数输出是低于还是高于。这个想法的灵感来自这个视频 https://youtu.be/DGxIcDjPzac 。我还想制作一个神经网络库,供我在以后的项目中使用。
我做错了什么?
在下面的 gif 中,我开始了训练,但似乎并不适用于所有要点。蓝线是函数 (y = x + 50),它上面的所有点都应该是绿色的,但不是。为了简化示例和更容易调试,我选择了一个简单的函数,这样我只能对模型使用感知。
我还创建了一个方法 backPropagationDebug(...)
来显示每一步中所有矩阵预测错误的点,但我找不到问题所在。
public void backPropagation(double[][] input,double[][] expected) {
double[][][] outputs = getoutputs(input);
double[][] currentOutput = outputs[outputs.length - 1];
double[][] currentError = Matrix.subtract(expected,currentOutput);
for (int i = brain.length - 1; i >= 0; i--) {
final double[][] layer = brain[i];
final double[][] prevIoUsOutput = outputs[i];
final double[][] layerTranspose = Matrix.transpose(layer);
final double[][] prevIoUsError = Matrix.multiply(layerTranspose,currentError);
/* FIST BIT */
double[][] errorSigmoid = Matrix.copyOf(currentError);
for (int k = 0; k < errorSigmoid.length; k++) {
errorSigmoid[k][0] *= - derivativeActivationFunction(currentOutput[k][0]);
}
/* SECOND BIT */
final double[][] slopeMatrix = Matrix.multiply(errorSigmoid,Matrix.transpose(prevIoUsOutput));
/* UPDATE THE WEIGHTS */
for (int k = 0; k < layer.length; k++) {
for (int l = 0; l < layer[0].length; L++) {
layer[k][l] = layer[k][l] - learningRate * slopeMatrix[k][l];
}
}
currentOutput = prevIoUsOutput;
currentError = prevIoUsError;
}
}
(来自:Tariq Rashid 制作您自己的神经网络)
代码在github上,可以轻松运行,因为它是一个gradle项目:https://github.com/StamateValentin/Artificial-Intelligence-Playground/tree/7a7446b7faedd7673bc53a62304ff3a5180d77eb
我使用的资源在 README.md 文件中。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)