層是節點的一個鋸齒形陣列,並且其表示的Theta陣列,每個節點作爲源[]和目的地[]。鏈接2個變量的一個對象
問題是,爲什麼當我改變第四行的代碼,第五行仍然打印「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;
你應該澄清'layers'陣列的填充方式。 – 2013-05-12 19:14:45
請張貼整個外部/嵌套循環(如果適用)代碼片段,因爲不清楚索引i和j來自哪裏。 Rgds, – 2013-05-12 19:16:12
將結構更改爲類,一切都將工作。隨着目前的使用,在那裏有結構是沒有意義的 – ashcliffe 2013-05-12 19:17:18