def test_wmape():
 skip_if_no_sklearn()
 trainer = yaml_parse.load(test_yaml)
 trainer.main_loop()
 X = trainer.model.get_input_space().make_theano_batch()
 Y = trainer.model.fprop(X)
 f = function([X], Y, allow_input_downcast=True)
 y_hat = f(trainer.dataset.X)
 wmape_num_exp = abs((trainer.dataset.y - y_hat)).sum()
 wmape_den_exp = abs(trainer.dataset.y).sum()
 exp_array = np.asarray([wmape_num_exp, wmape_den_exp])
 wmape_num_real = trainer.model.monitor.channels['train_wmape_num'].val_record
 wmape_den_real = trainer.model.monitor.channels['train_wmape_den'].val_record
 real_array = np.asarray([wmape_num_real[(-1)], wmape_den_real[(-1)]])
 assert_allclose(exp_array, real_array)

def test_wmape ( ) : skip_if_no_sklearn ( ) trainer = yaml_parse . load ( test_yaml ) trainer . main_loop ( ) X = trainer . model . get_input_space ( ) . make_theano_batch ( ) Y = trainer . model . fprop ( X ) f = function ( [ X ] , Y , allow_input_downcast = True ) y_hat = f ( trainer . dataset . X ) wmape_num_exp = abs ( ( trainer . dataset . y - y_hat ) ) . sum ( ) wmape_den_exp = abs ( trainer . dataset . y ) . sum ( ) exp_array = np . asarray ( [ wmape_num_exp , wmape_den_exp ] ) wmape_num_real = trainer . model . monitor . channels [ 'train_wmape_num' ] . val_record wmape_den_real = trainer . model . monitor . channels [ 'train_wmape_den' ] . val_record real_array = np . asarray ( [ wmape_num_real [ ( - 1 ) ] , wmape_den_real [ ( - 1 ) ] ] ) assert_allclose ( exp_array , real_array )
test wmapechannel .