ottokart / punctuator2

A bidirectional recurrent neural network model with attention mechanism for restoring missing punctuation in unsegmented text
http://bark.phon.ioc.ee/punctuator
MIT License
659 stars 195 forks source link

Adapting from previous model state #10

Open aliabbasjp opened 7 years ago

aliabbasjp commented 7 years ago
print "Building model..."
        net = models.GRUstage2(
            rng=rng,
            x=x,
            minibatch_size=MINIBATCH_SIZE,
            n_hidden=num_hidden,
            x_vocabulary=word_vocabulary,
            y_vocabulary=punctuation_vocabulary,
            stage1_model_file_name=prev_model_file_name
        )
Number of parameters is 13667593
/theano/scan_module/scan.py", line 475, in scan
    actual_slice = seq['input'][k - mintap]
TypeError: 'NoneType' object has no attribute '__getitem_

On adapting to previously trained model file over a new data set , I find above error, I dont supply any pause info so its by default null

ottokart commented 7 years ago

Hi,

thanks for reporting!

It should actually work if you don't make any changes to the original main2.py script (I see you have removed the "p=p" line). Current implementation is rather memory inefficient -- even when there are no tags present in the text, the processed dataset will have all-zeros pause arrays in it which are fed to the network during training. Haven't had a good excuse to optimize that yet.

aliabbasjp commented 7 years ago

@ottokart p=None as I dont have pause info.

ottokart commented 7 years ago

@aliabbasjp yes, I understand, but try with unmodified code and follow the instructions in the readme (slighlty modified below):

Data preparation. In there should be .test.txt, .dev.txt and other *.txt (for training) files just as in . Pause info not needed (no tags necessary):

python data.py <data_dir> <adaptation_data_dir>

The first stage can be trained with:

python main.py <model_name> <hidden_layer_size> <learning_rate>

Adaptation stage can be trained with:

python main2.py <adapted_model_name> <hidden_layer_size> <learning_rate> <first_stage_model_path>

Let me know, if you still get some error or if some parts of the readme are unclearly written.

aliabbasjp commented 7 years ago

ok I was manage to get it trained!

but on testing with punctuator.py I get following error, as I dont supply pause info on test set either.

    if use_pauses:
        print "Using pauses"

        p = T.matrix('p')

        print "Loading model parameters..."
        net, _ = models.load(model_file, 1, x, p)

        print "Building model..."
        predict = theano.function(
            inputs=[x, p],
            outputs=net.y
        )

Above code is used for loading the model gives following error:

self.inv_finder[c]))
TypeError: Missing required input: p

How can I give a dummy p in test set when I wont be having pause info during evaluation?

aliabbasjp commented 7 years ago

@ottokart Basically I only need target domain adaptation without pause features. So I need to send an empty array of pauses to run punctuator.py, how to do that?

ottokart commented 7 years ago

added dummy pauses into punctuator.py script. Can you pull the new version and try something like:

cat data.dev.txt | python punctuator.py <model_path> <model_output_path> 1

That 1 in the end is important.