def get_predictions(model, valid_set, time_steps, beam_search=True, num_beams=5):
 shape = (valid_set.nbatches, model.be.bsz, time_steps)
 if beam_search:
  ypred = model.get_outputs_beam(valid_set, num_beams=num_beams)
  prediction = ypred.reshape(shape).transpose(1, 0, 2)
 else:
  ypred = model.get_outputs(valid_set)
  prediction = ypred.argmax(2).reshape(shape).transpose(1, 0, 2)
 groundtruth = valid_set.X[:, :valid_set.nbatches, ::(-1)]
 prediction = prediction[:, :, ::(-1)].flatten()
 groundtruth = groundtruth[:, :, ::(-1)].flatten()
 return (prediction, groundtruth)

def get_predictions ( model , valid_set , time_steps , beam_search = True , num_beams = 5 ) : shape = ( valid_set . nbatches , model . be . bsz , time_steps ) if beam_search : ypred = model . get_outputs_beam ( valid_set , num_beams = num_beams ) prediction = ypred . reshape ( shape ) . transpose ( 1 , 0 , 2 ) else : ypred = model . get_outputs ( valid_set ) prediction = ypred . argmax ( 2 ) . reshape ( shape ) . transpose ( 1 , 0 , 2 ) groundtruth = valid_set . X [ : , : valid_set . nbatches , : : ( - 1 ) ] prediction = prediction [ : , : , : : ( - 1 ) ] . flatten ( ) groundtruth = groundtruth [ : , : , : : ( - 1 ) ] . flatten ( ) return ( prediction , groundtruth )
get model outputs for displaying .