original_docstring:  Sanity check for question 1e. 
          Compares student output to that of model with dummy data.
      
docstring: Sanity check for question 1e.
  Compares student output to that of model with dummy data.
docstring_tokens: Sanity check for question 1e . Compares student output to that of model with dummy data .
code: def question_1e_sanity_check(model, src_sents, tgt_sents, vocab):
      """ Sanity check for question 1e. 
          Compares student output to that of model with dummy data.
      """
      print("-"*80)
      print("Running Sanity Check for Question 1e: Decode")
      print("-"*80)
  
      # Load Inputs
      dec_init_state = torch.load('./sanity_check_en_es_data/dec_init_state.pkl')
      enc_hiddens = torch.load('./sanity_check_en_es_data/enc_hiddens.pkl')
      enc_masks = torch.load('./sanity_check_en_es_data/enc_masks.pkl')
      target_padded = torch.load('./sanity_check_en_es_data/target_padded.pkl')
  
      # Load Outputs
      combined_outputs_target = torch.load('./sanity_check_en_es_data/combined_outputs.pkl')
      print(combined_outputs_target.shape)
  
      # Configure for Testing
      reinitialize_layers(model)
      COUNTER = [0]
      def stepFunction(Ybar_t, dec_state, enc_hiddens, enc_hiddens_proj, enc_masks):
         dec_state = torch.load('./sanity_check_en_es_data/step_dec_state_{}.pkl'.format(COUNTER[0]))
         o_t = torch.load('./sanity_check_en_es_data/step_o_t_{}.pkl'.format(COUNTER[0]))
         COUNTER[0]+=1
         return dec_state, o_t, None
      model.step = stepFunction
  
      # Run Tests
      with torch.no_grad():
          combined_outputs_pred = model.decode(enc_hiddens, enc_masks, dec_init_state, target_padded)
      assert(np.allclose(combined_outputs_pred.numpy(), combined_outputs_target.numpy())), "combined_outputs is incorrect: it should be:\n {} but is:\n{}".format(combined_outputs_target, combined_outputs_pred)
      print("combined_outputs Sanity Checks Passed!")
      print("-"*80)
      print("All Sanity Checks Passed for Question 1e: Decode!")
      print("-"*80)
code_tokens: def question_1e_sanity_check ( model , src_sents , tgt_sents , vocab ) : print ( "-" * 80 ) print ( "Running Sanity Check for Question 1e: Decode" ) print ( "-" * 80 ) dec_init_state = torch . load ( './sanity_check_en_es_data/dec_init_state.pkl' ) enc_hiddens = torch . load ( './sanity_check_en_es_data/enc_hiddens.pkl' ) enc_masks = torch . load ( './sanity_check_en_es_data/enc_masks.pkl' ) target_padded = torch . load ( './sanity_check_en_es_data/target_padded.pkl' ) combined_outputs_target = torch . load ( './sanity_check_en_es_data/combined_outputs.pkl' ) print ( combined_outputs_target . shape ) reinitialize_layers ( model ) COUNTER = [ 0 ] def stepFunction ( Ybar_t , dec_state , enc_hiddens , enc_hiddens_proj , enc_masks ) : dec_state = torch . load ( './sanity_check_en_es_data/step_dec_state_{}.pkl' . format ( COUNTER [ 0 ] ) ) o_t = torch . load ( './sanity_check_en_es_data/step_o_t_{}.pkl' . format ( COUNTER [ 0 ] ) ) COUNTER [ 0 ] += 1 return dec_state , o_t , None model . step = stepFunction with torch . no_grad ( ) : combined_outputs_pred = model . decode ( enc_hiddens , enc_masks , dec_init_state , target_padded ) assert ( np . allclose ( combined_outputs_pred . numpy ( ) , combined_outputs_target . numpy ( ) ) ) , "combined_outputs is incorrect: it should be:\n {} but is:\n{}" . format ( combined_outputs_target , combined_outputs_pred ) print ( "combined_outputs Sanity Checks Passed!" ) print ( "-" * 80 ) print ( "All Sanity Checks Passed for Question 1e: Decode!" ) print ( "-" * 80 )
short_docstring: Sanity check for question 1e.
short_docstring_tokens: Sanity check for question 1e .
comment: """ Sanity check for question 1e. 
          Compares student output to that of model with dummy data.
      """$SEP$# Load Inputs$SEP$# Load Outputs$SEP$# Configure for Testing$SEP$# Run Tests