gau820827 / AI-writer_Data2Doc

PyTorch Implementation of NBA game summary generator.
Apache License 2.0
83 stars 22 forks source link

Local variable "out" might be reference before assignment in train.py #17

Closed frankxu2004 closed 6 years ago

frankxu2004 commented 6 years ago

It seems that in train.py line 82-101, the variable out seems to be not assigned if the encoder type is BiLSTM.

    # Encoding
    if ENCODER_STYLE == 'BiLSTM':
        init_hidden = encoder.initHidden(batch_length)
        encoder_hidden, encoder_hiddens = encoder(rt, re, rm, init_hidden)

        # Store memory information
        for ei in range(input_length):
            encoder_outputs[:, ei] = encoder_hiddens[:, ei]

    else:
        encoder_hidden = encoder.initHidden(batch_length)
        out, encoder_hidden = encoder(rt, re, rm, encoder_hidden)

        # Store memory information
        encoder_outputs = out.permute(1,0,2)

    decoder_hidden = decoder.initHidden(batch_length)
    decoder_hidden[0,:,:] = out[-1,:] # THE out HERE MAY NOT BE ASSIGNED IF BILSTM
gau820827 commented 6 years ago

Fixed.