Reputation: 43
At the moment I am working on AI in AHK.
Now I have the problem that I don't know how to deal with a matrix. See below an example matrix:
WeightLooper := 1
Loop %NumberOfWeightsLayerTotal%
{
Random, Weight_%WeightLooper%, -1.0, 1.0
WeightLooper := WeightLooper + 1
}
WEIGHTS_1 := Array([Weight_1, Weight_2, Weight_3, Weight_4], [Weight_5, Weight_6, Weight_7, Weight_8], [Weight_9, Weight_10, Weight_11, Weight_12])
TRAINING_INPUTS := []
rows := (LastFilledY - 1)
columns := (LastFilledX - 1)
Xas := 0
Yas := 0
Loop, % rows
{
Xas := 0
Yas := Yas + 1
row := []
Loop, % columns
{
Xas := Xas + 1
row.push(myarray[Yas][Xas])
}
TRAINING_INPUTS.push(row)
}
Now I have a matrix of 3x4. Suppose I want a matrix of 10x10, how do I do that? So basically I want to create a variable matrix.
I ask this because my input (csv file) can vary from 2x2 to 1000000x1000000.
Upvotes: 1
Views: 369
Reputation: 6499
I'd probably recommend pushing a new array into the array in a loop:
WEIGHTS_1 := []
rows := 5
columns := 7
Loop, % rows
{
row := []
Loop, % columns
{
Random, weight, -1.0, 1.0
row.push(weight)
}
WEIGHTS_1.push(row)
}
Example output:
[[-0.678368, -0.768605, -0.274922, 0.049760, -0.133968, -0.876030, -0.235799]
,[-0.296078, 0.359816, -0.461632, 0.788800, -0.707147, -0.200223, -0.473914]
,[0.474090, 0.085090, 0.458321, -0.820574, 0.145089, 0.193249, 0.990545]
,[0.205461, 0.901953, -0.137901, 0.279726, 0.562361, -0.019861, -0.887540]
,[0.504811, -0.876628, -0.127397, 0.156817, 0.873983, 0.859992, -0.879222]]
Upvotes: 4