def __init__(self, shape=None, data_type=None, needs_gradient=False, is_sparse=False, dynamic_axes = [Axis.default_dynamic_axis(), Axis.default_batch_axis()], name=''): shape = utils.sanitize_shape(shape) if data_type is None: data_type = FLOAT_32 dtype = utils.sanitize_dtype_cntk(data_type) super(Variable, self).__init__(shape, is_sparse, dtype, needs_gradient, name, dynamic_axes)
break trainer.train_minibatch(data) loss_numer += trainer.previous_minibatch_loss_average() * trainer.previous_minibatch_sample_count() # too much code for something this simple loss_denom += trainer.previous_minibatch_sample_count() metric_numer += trainer.previous_minibatch_evaluation_average() * trainer.previous_minibatch_sample_count() metric_denom += trainer.previous_minibatch_sample_count() print_training_progress(trainer, mbs if mbs > 10 else 0, num_mbs_to_show_result) t += num_samples[slot_labels] #print (num_samples[slot_labels], t) mbs += 1 print("--- EPOCH {} DONE: loss = {:0.6f} * {}, metric = {:0.1f}% * {} ---".format(epoch+1, loss_numer/loss_denom, loss_denom, metric_numer/metric_denom*100.0, metric_denom)) return loss_numer/loss_denom, metric_numer/metric_denom ############################# # main function boilerplate # ############################# if __name__=='__main__': # TODO: get closure on Amit's feedback "Not the right pattern as we discussed over email. Please change to set_default_device(gpu(0))" #set_gpu(0) #set_computation_network_trace_level(1) # TODO: remove debugging facilities once this all works reader = create_reader(data_dir + "/atis.train.ctf") model = create_model(_inf=_Infer(shape=input_dim, axis=[Axis.default_batch_axis(), Axis.default_dynamic_axis()])) # TODO: Currently this fails with a mismatch error if axes ^^ are given in opposite order. I think it shouldn't. # train train(reader, model, max_epochs=8) # test (TODO) reader = create_reader(data_dir + "/atis.test.ctf") #test(reader, model_dir + "/slu.cmf") # TODO: what is the correct pattern here?
def main(): #set_computation_network_trace_level(1) # TODO: remove debugging facilities once this all works reader = create_reader(data_dir + "/atis.train.ctf") model = create_model(_inf=_Infer(shape=input_dim, axis=[Axis.default_batch_axis(), Axis.default_dynamic_axis()])) # TODO: Currently this fails with a mismatch error if axes ^^ are given in opposite order. I think it shouldn't. # train train(reader, model, max_epochs=8) # test (TODO) reader = create_reader(data_dir + "/atis.test.ctf")