zhongkaifu / RNNSharp

RNNSharp is a toolkit of deep recurrent neural network which is widely used for many different kinds of tasks, such as sequence labeling, sequence-to-sequence and so on. It's written by C# language and based on .NET framework 4.6 or above versions. RNNSharp supports many different types of networks, such as forward and bi-directional network, sequence-to-sequence network, and different types of layers, such as LSTM, Softmax, sampled Softmax and others.
BSD 3-Clause "New" or "Revised" License
285 stars 91 forks source link

ArgumentOutOfRangeException during training #3

Closed bratao closed 8 years ago

bratao commented 8 years ago

Hello !

First of all, thank you for publishing such high quality project. It is the absolute state-of-art ! Thank you !!!

I was evaluating this in a small dataset, however I get this ArgumentOutOfRangeException.

The error is in SimpleRNN.cs, at this part:

Logger.WriteLine("Saving feature2hidden weights...");
saveMatrixBin(mat_feature2hidden, fo);

This matrix, mat_feature2hidden, have the Height of 200, however the Width is 0.

The command: .\Bin\RNNSharpConsole.exe -mode train -trainfile bruno-data.txt -modelfile .\bruno-model.bin -validfile bruno-valid.txt -ftrfile .\config_bruno.txt -tagfile .\bruno-tags.txt -modeltype 0 -layersize 200 -alpha 0.1 -crf 1 -maxiter 0 -savestep 200K -dir 1 -dropout 0

The config:
#The file name for template feature set
TFEATURE_FILENAME:.\bruno-features
#The context range for template feature set. In below, the context is current token, next token and next after next token
TFEATURE_CONTEXT: 0

And the error:

info,11/02/2016 14:25:38 Distortion: 0,0873744581246124, vqSize: 256
info,11/02/2016 14:25:38 Saving feature2hidden weights...
info,11/02/2016 14:25:38 Saving matrix with VQ 256...
info,11/02/2016 14:25:38 Sorting data set (size: 0)...

Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at AdvUtils.VarBigArray`1.get_Item(Int64 offset)
   at AdvUtils.VectorQuantization.BuildCodebook(Int32 vqSize)
   at RNNSharp.RNN.saveMatrixBin(Matrix`1 mat, BinaryWriter fo, Boolean BuildVQ) in C:\github\RNNSharp\RNNSharp\RNN.cs:line 138
   at RNNSharp.SimpleRNN.saveNetBin(String filename) in C:\github\RNNSharp\RNNSharp\SimpleRNN.cs:line 517
   at RNNSharp.BiRNN.saveNetBin(String filename) in C:\github\RNNSharp\RNNSharp\BiRNN.cs:line 499
   at RNNSharp.RNNEncoder.Train() in C:\github\RNNSharp\RNNSharp\RNNEncoder.cs:line 107
   at RNNSharpConsole.Program.Main(String[] args) in C:\github\RNNSharp\RNNSharpConsole\Program.cs:line 279

Maybe it is because I'm not using a word embedding ??

Thank you again for this great project !

bratao commented 8 years ago

It was the missing word embedding !

zhongkaifu commented 8 years ago

Thanks. RNNSharp should not crash, even word embedding feature is not used. I will fix it.