Skip to content

Commit

Permalink
Fix for LSTM edge case (minibatch size of 1) after recent TAD changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDBlack committed Apr 30, 2016
1 parent 6a0efff commit d27bd78
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public RnnOutputLayer(NeuralNetConfiguration conf, INDArray input) {
private INDArray reshape3dTo2d(INDArray in){
if( in.rank() != 3 ) throw new IllegalArgumentException("Invalid input: expect NDArray with rank 3");
int[] shape = in.shape();
if(shape[0]==1) return in.tensorAlongDimension(0,1,2); //Edge case: miniBatchSize==1
if(shape[0]==1) return in.tensorAlongDimension(0,1,2).permutei(1,0); //Edge case: miniBatchSize==1
if(shape[2]==1) return in.tensorAlongDimension(0,1,0); //Edge case: timeSeriesLength=1
INDArray permuted = in.permute(0, 2, 1); //Permute, so we get correct order after reshaping
return permuted.reshape(shape[0] * shape[2], shape[1]);
Expand Down

0 comments on commit d27bd78

Please sign in to comment.