JonathanRaiman / theano_lstm

:microscope: Nano size Theano LSTM module
Other
304 stars 111 forks source link

Fixed param setter functions to support saving/loading model parameters ... #5

Closed mheilman closed 9 years ago

mheilman commented 9 years ago

I just noticed that the param setter methods that I added in my previous pull request didn't actually work for saving and loading models. The setter methods needed to use the get_value and set_value methods rather than just assigning new shared variables.

I also added the clip_gradients keyword argument to the StackedCells class so that it can be applied to component layers. I'm not sure this is actually useful, but I wanted to try clip_gradients in a model with stacked cells.

mheilman commented 9 years ago

Here's a simplified version of how I am using the StackedCells.params getter and setter methods to save and load models. It seems to work now.

with open(args.save_path, 'wb') as f:
   pickle.dump(model.params, f, protocol=pickle.HIGHEST_PROTOCOL)
model = create_new_model()
with open(args.load_path, 'rb') as f:
    model.params = pickle.load(f)