Skip to content

Commit

Permalink
Adapted to new reader format
Browse files Browse the repository at this point in the history
  • Loading branch information
wilrich-msft committed Mar 22, 2016
1 parent 832db4d commit 2d500de
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions contrib/Python/cntk/examples/LogReg/logreg.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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])

0 comments on commit 2d500de

Please sign in to comment.