diff --git a/contrib/Python/cntk/examples/LogReg/logreg.py b/contrib/Python/cntk/examples/LogReg/logreg.py index badd9068885c..d37ad628a19c 100644 --- a/contrib/Python/cntk/examples/LogReg/logreg.py +++ b/contrib/Python/cntk/examples/LogReg/logreg.py @@ -1,11 +1,14 @@ +import os import sys -sys.path.insert(0, r"F:\cntk\LanguageBindings\Python") +sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) from cntk import * if (__name__ == "__main__"): - x = Input(2, var_name='x') - y = Input(3, var_name='y') + x = Input(2) + x.attach_uci_fast_reader("Train-3Classes.txt", 0) + y = Input(3) + x.attach_uci_fast_reader("Train-3Classes.txt", 2) w = LearnableParameter(3, 2) b = LearnableParameter(3, 1) t = Times(w, x) @@ -14,18 +17,11 @@ ec = CrossEntropyWithSoftmax(y, out) ec.tag = 'criterion' - reader = UCIFastReader( - "Train-3Classes.txt", "y", "1", "2", "3", "SimpleMapping-3Classes.txt") - reader.add_input('x', 0, 2) - reader.add_input('y', 2, 1) - my_sgd = SGD( epoch_size=0, minibatch_size=25, learning_ratesPerMB=0.1, max_epochs=3) - with Context('demo', optimizer=my_sgd, root_node= ec, clean_up=False) as ctx: - input_map = {x: (reader, (0, 2)), y: (reader, (2, 1))} - ctx.train(reader) + with Context('demo', optimizer=my_sgd, root_node=ec, clean_up=False) as ctx: + ctx.train(None) - #import ipdb;ipdb.set_trace() - result = ctx.eval(out, input_map) + result = ctx.eval(out) print(result[:3])