Skip to content

Commit

Permalink
Merge pull request deeplearning4j#1469 from deeplearning4j/ab_1454_ls…
Browse files Browse the repository at this point in the history
…tmedgecases

Fix for LSTM edge case (minibatch size of 1) after recent TAD changes
  • Loading branch information
AlexDBlack committed Apr 30, 2016
2 parents c8724ab + d27bd78 commit 5d52dd6
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 5d52dd6

Please sign in to comment.