Function works with LIVE but not with PLAYBACK - different dimensions?
Hi forum!,
I am working on a project in which we have a function to set the weights and bias for an artificial neural network. It works perfectly fine when we use it LIVE. But when we try PLAYBACK there is an error with the dimensions.
Do you know if LIVE and PLAYBACK need different processings in the code?
Below is the function that has the error. It is in line "tempW[rowCount][i] = float(weightArray[i]);" and the error is ArrayIndexOutOfBoundsException. For this reason I think that there might be a difference in the dimensions of the data source.
I hope you can help me with this!
Thanks in advance,
Agustina
void setWeightsAndBias(String wFName, String bFName, int nLayer){
BufferedReader weightsReader = createReader(this.wbDir+ wFName + ".csv");
BufferedReader biasReader = createReader(this.wbDir + bFName + ".csv");
String line = null;
int rowCount = 0;
LayerConnection_Bias layer = this.layers.get(nLayer);
int WRows = layer.getWeights().length ;
int WCols = layer.getWeights()[0].length;
float[][] tempW = new float[WRows][WCols];
float[] tempBias = new float[WCols];
try{
// Read and set weights
while ((line = weightsReader.readLine()) != null){
String[] weightArray = split(line, ",");
for (int i=0; i < WCols; i++){ // one row of weights
//println(i);
tempW[rowCount][i] = float(weightArray[i]);
//println(weightArray[i]);
}
rowCount++;
if (rowCount == WRows){
// Mat.print(tempW, 3);
this.layers.get(nLayer).setWeights(tempW);
}
}
// Read and set bias
int i = 0;
while ((line = biasReader.readLine()) != null){
tempBias[i] = float(line);
i++;
}
this.layers.get(nLayer).setBias(tempBias);
}catch(IOException e){
e.printStackTrace();
}
}
Comments
If you are trying to add Neural Networks to the GUI, that is pretty cool! It may benefit the entire Community to share more details.
Based on this post, it's not clear how you are integrating this function with existing GUI code. Also, the entire data flow has been refactored for the upcoming GUI v5.
CSV files generated by the GUI have other columns that contain data from Aux channels and timestamps.
Agustina, hi.
"It works perfectly fine when we use it LIVE."
How are you doing the live version of the program? The code above looks like Java code. Is your live version receiving an LSL stream from the GUI?
William