Layers 是 Node 的锯齿状数组,每个节点作为 source[] 和 destination[] 代表 Theta 的数组。
问题是,为什么当我更改第四行的代码时,链接这些对象后第五行仍然打印“0”?
theta t = new theta();
layers[1][i].source[j] = t;
layers[0][j].destination[i] = t;
layers[0][j].destination[i].weight = 5;
Console.WriteLine(layers[1][i].source[j].weight);
struct theta
{
public double weight;
public theta(double _weight) { weight = _weight; }
}
class node
{
public theta[] source;
public theta[] destination;
public double activation;
public double delta;
public node() { }
public node(double x) { activation = x; }
}
关于如何填充图层的示例:
node n = new node();
n.destination = new theta[numberOfNodesPerHiddenLayer+1];
n.source = new theta[numberOfNodesPerHiddenLayer+1];
layers[i][j] = n;