jiweil / Neural-Dialogue-Generation

MIT License
830 stars 214 forks source link

Bug in Persona_Addressee/data.lua #17

Open cgsdfc opened 5 years ago

cgsdfc commented 5 years ago

There is a bug in Persona_Addressee/data.lua, the read_train(open_train_file) function.

When self.params.speakerSetting == "speaker", the AddresseeID won't be set to a non-nil value. So the line AddresseeID = AddresseeID:cuda() will trigger an error, as shown here:

/root/torch/install/bin/luajit: ./Persona/Dataset.lua:83: attempt to index local 'AddresseeID' (a nil value)
stack traceback:
        ./Persona/Dataset.lua:83: in function 'read_train'
        ./Persona/Model.lua:123: in function 'test'
        ./Persona/Model.lua:159: in function 'train'
        Persona/train.lua:16: in main chunk
        [C]: in function 'dofile'
        /root/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
        [C]: at 0x00406670

This is not hard to tell from the code by inspecting the control flow carefully. And it will happen when the default setting of command line arguments are in use.

Judging from the other parts of your code, where the speaker setting is handled correctly, the fix proposed here will be a simple guard against the problematic statement.

if AddresseeID then -- Optional
    AddresseeID = AddresseeID:cuda()
end
cgsdfc commented 5 years ago

I rename the file data.lua to Dataset.lua.