(decoder, char_vocab)
Sanity check for CharDecoder.forward()
        basic shape check
Sanity check for CharDecoder.forward()
        basic shape check
Sanity check for CharDecoder . forward () basic shape check
def question_2b_sanity_check(decoder, char_vocab):
    """ Sanity check for CharDecoder.forward()
        basic shape check
    """
    print ("-"*80)
    print("Running Sanity Check for Question 2b: CharDecoder.forward()")
    print ("-"*80)
    sequence_length = 4
    inpt = torch.zeros(sequence_length, BATCH_SIZE, dtype=torch.long)
    logits, (dec_hidden1, dec_hidden2) = decoder.forward(inpt)
    logits_expected_size = [sequence_length, BATCH_SIZE, len(char_vocab.char2id)]
    dec_hidden_expected_size = [1, BATCH_SIZE, HIDDEN_SIZE]
    assert(list(logits.size()) == logits_expected_size), "Logits shape is incorrect:\n it should be {} but is:\n{}".format(logits_expected_size, list(logits.size()))
    assert(list(dec_hidden1.size()) == dec_hidden_expected_size), "Decoder hidden state shape is incorrect:\n it should be {} but is: {}".format(dec_hidden_expected_size, list(dec_hidden1.size()))
    assert(list(dec_hidden2.size()) == dec_hidden_expected_size), "Decoder hidden state shape is incorrect:\n it should be {} but is: {}".format(dec_hidden_expected_size, list(dec_hidden2.size()))
    print("Sanity Check Passed for Question 2b: CharDecoder.forward()!")
    print("-"*80)
def question_2b_sanity_check ( decoder , char_vocab ) : print ( "-" * 80 ) print ( "Running Sanity Check for Question 2b: CharDecoder.forward()" ) print ( "-" * 80 ) sequence_length = 4 inpt = torch . zeros ( sequence_length , BATCH_SIZE , dtype = torch . long ) logits , ( dec_hidden1 , dec_hidden2 ) = decoder . forward ( inpt ) logits_expected_size = [ sequence_length , BATCH_SIZE , len ( char_vocab . char2id ) ] dec_hidden_expected_size = [ 1 , BATCH_SIZE , HIDDEN_SIZE ] assert ( list ( logits . size ( ) ) == logits_expected_size ) , "Logits shape is incorrect:\n it should be {} but is:\n{}" . format ( logits_expected_size , list ( logits . size ( ) ) ) assert ( list ( dec_hidden1 . size ( ) ) == dec_hidden_expected_size ) , "Decoder hidden state shape is incorrect:\n it should be {} but is: {}" . format ( dec_hidden_expected_size , list ( dec_hidden1 . size ( ) ) ) assert ( list ( dec_hidden2 . size ( ) ) == dec_hidden_expected_size ) , "Decoder hidden state shape is incorrect:\n it should be {} but is: {}" . format ( dec_hidden_expected_size , list ( dec_hidden2 . size ( ) ) ) print ( "Sanity Check Passed for Question 2b: CharDecoder.forward()!" ) print ( "-" * 80 )