fixed 202 and 203 tutorials
This commit is contained in:
Родитель
5d4d855407
Коммит
cbc27a94ca
|
@ -23,23 +23,6 @@ build/
|
|||
.run-*
|
||||
lib/
|
||||
bin/
|
||||
Examples/Image/DataSets/Pascal/VOC*
|
||||
Examples/Image/DataSets/Pascal/selective_search_data*
|
||||
Examples/Image/Detection/FastRCNN/proc/
|
||||
Examples/Image/DataSets/CIFAR-10/CIFAR-10_mean.xml
|
||||
Examples/Image/DataSets/CIFAR-10/Test_cntk_text.txt
|
||||
Examples/Image/DataSets/CIFAR-10/Train_cntk_text.txt
|
||||
Examples/Image/DataSets/CIFAR-10/cifar-10-batches-py/
|
||||
Examples/Image/DataSets/CIFAR-10/test/
|
||||
Examples/Image/DataSets/CIFAR-10/test_map.txt
|
||||
Examples/Image/DataSets/CIFAR-10/test_regrLabels.txt
|
||||
Examples/Image/DataSets/CIFAR-10/train/
|
||||
Examples/Image/DataSets/CIFAR-10/train_map.txt
|
||||
Examples/Image/DataSets/CIFAR-10/train_regrLabels.txt
|
||||
Examples/Image/DataSets/MNIST/Test-28x28_cntk_text.txt
|
||||
Examples/Image/DataSets/MNIST/Train-28x28_cntk_text.txt
|
||||
Examples/Image/DataSets/grocery/
|
||||
Examples/Image/PretrainedModels/
|
||||
|
||||
|
||||
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||
|
@ -237,5 +220,31 @@ bindings/python/cntk/c_plus_c.mod
|
|||
bindings/python/cntk/i_plus_c_0.mod
|
||||
bindings/python/cntk/i_plus_i_0.mod
|
||||
|
||||
# Examples and Tutorials
|
||||
Examples/Image/DataSets/Pascal/VOC*
|
||||
Examples/Image/DataSets/Pascal/selective_search_data*
|
||||
Examples/Image/Detection/FastRCNN/proc/
|
||||
Examples/Image/DataSets/CIFAR-10/CIFAR-10_mean.xml
|
||||
Examples/Image/DataSets/CIFAR-10/Test_cntk_text.txt
|
||||
Examples/Image/DataSets/CIFAR-10/Train_cntk_text.txt
|
||||
Examples/Image/DataSets/CIFAR-10/cifar-10-batches-py/
|
||||
Examples/Image/DataSets/CIFAR-10/test/
|
||||
Examples/Image/DataSets/CIFAR-10/test_map.txt
|
||||
Examples/Image/DataSets/CIFAR-10/test_regrLabels.txt
|
||||
Examples/Image/DataSets/CIFAR-10/train/
|
||||
Examples/Image/DataSets/CIFAR-10/train_map.txt
|
||||
Examples/Image/DataSets/CIFAR-10/train_regrLabels.txt
|
||||
Examples/Image/DataSets/MNIST/Test-28x28_cntk_text.txt
|
||||
Examples/Image/DataSets/MNIST/Train-28x28_cntk_text.txt
|
||||
Examples/Image/DataSets/grocery/
|
||||
Examples/Image/PretrainedModels/
|
||||
Tutorials/HelloWorld-LogisticRegression/LR.txt.p
|
||||
Tutorials/HelloWorld-LogisticRegression/Models/
|
||||
Tutorials/.ipynb_checkpoints/
|
||||
Tutorials/atis.test.ctf
|
||||
Tutorials/atis.train.ctf
|
||||
Tutorials/data/
|
||||
Tutorials/dqn.mod
|
||||
Tutorials/pg.mod
|
||||
Tutorials/query.wl
|
||||
Tutorials/slots.wl
|
||||
|
|
|
@ -87,12 +87,10 @@ elif datasetName.startswith("pascalVoc"):
|
|||
'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor')
|
||||
lutImageSet = {"train": "trainval", "test": "test"}
|
||||
|
||||
# use cntk_nrRois = 4000. more than 99% of the test images have less than 4000 rois, but 50% more than 2000
|
||||
# model training / scoring
|
||||
classifier = 'nn'
|
||||
|
||||
#more than 99% of the test images have less than 4000 rois, but 50% more than 2000
|
||||
cntk_nrRois = 4000
|
||||
|
||||
# database
|
||||
imdbs = dict()
|
||||
for image_set, year in zip(["train", "test"], ["2007", "2007"]):
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
"from cntk.utils import ProgressPrinter, log_number_of_parameters\n",
|
||||
"from cntk.io import MinibatchSource, CTFDeserializer\n",
|
||||
"from cntk.io import StreamDef, StreamDefs, INFINITELY_REPEAT, FULL_DATA_SWEEP\n",
|
||||
"from cntk import future_value, combine, Trainer, cross_entropy_with_softmax, classification_error, splice\n",
|
||||
"from cntk import *\n",
|
||||
"from cntk.learner import adam_sgd, learning_rate_schedule"
|
||||
]
|
||||
},
|
||||
|
@ -379,16 +379,17 @@
|
|||
" # do other stuff (e.g. checkpointing, adjust learning rate, etc.)\n",
|
||||
" # (we don't run this many epochs, but if we did, these are good values)\n",
|
||||
" lr_per_sample = [0.003]*4+[0.0015]*24+[0.0003]\n",
|
||||
" lr_schedule = learning_rate_schedule(lr_per_sample, units=epoch_size)\n",
|
||||
" lr_per_minibatch = [x * minibatch_size for x in lr_per_sample]\n",
|
||||
" lr_schedule = learning_rate_schedule(lr_per_minibatch, UnitType.minibatch, epoch_size)\n",
|
||||
" \n",
|
||||
" # Momentum (could also be on a schedule)\n",
|
||||
" momentum_as_time_constant = 700\n",
|
||||
" # Momentum\n",
|
||||
" momentum_as_time_constant = momentum_as_time_constant_schedule(700)\n",
|
||||
" \n",
|
||||
" # We use a variant of the Adam optimizer which is known to work well on this dataset\n",
|
||||
" # Feel free to try other optimizers from \n",
|
||||
" # https://www.cntk.ai/pythondocs/cntk.learner.html#module-cntk.learner\n",
|
||||
" learner = adam_sgd(criterion.parameters,\n",
|
||||
" lr_per_sample=lr_schedule, momentum_time_constant=momentum_as_time_constant,\n",
|
||||
" lr=lr_schedule, momentum=momentum_as_time_constant,\n",
|
||||
" low_memory=True,\n",
|
||||
" gradient_clipping_threshold_per_sample=15, gradient_clipping_with_truncation=True)\n",
|
||||
"\n",
|
||||
|
@ -491,8 +492,10 @@
|
|||
" criterion.replace_placeholders({criterion.placeholders[0]: Input(num_labels)})\n",
|
||||
"\n",
|
||||
" # process minibatches and perform evaluation\n",
|
||||
" lr_schedule = learning_rate_schedule(1, UnitType.minibatch)\n",
|
||||
" momentum_as_time_constant = momentum_as_time_constant_schedule(0)\n",
|
||||
" dummy_learner = adam_sgd(criterion.parameters, \n",
|
||||
" lr_per_sample=1, momentum_time_constant=0, low_memory=True)\n",
|
||||
" lr=lr_schedule, momentum=momentum_as_time_constant, low_memory=True)\n",
|
||||
" evaluator = Trainer(model, criterion.outputs[0], criterion.outputs[1], dummy_learner)\n",
|
||||
" progress_printer = ProgressPrinter(tag='Evaluation')\n",
|
||||
"\n",
|
||||
|
|
|
@ -252,8 +252,8 @@
|
|||
" meas = reduce_mean(square(model - q_target), axis=0)\n",
|
||||
"\n",
|
||||
" # optimizer=opt\n",
|
||||
" lr /= BATCH_SIZE\n",
|
||||
" learner = sgd(model.parameters, lr, gradient_clipping_threshold_per_sample=10)\n",
|
||||
" lr_schedule = learning_rate_schedule(lr, UnitType.minibatch)\n",
|
||||
" learner = sgd(model.parameters, lr_schedule, gradient_clipping_threshold_per_sample=10)\n",
|
||||
" trainer = Trainer(model, loss, meas, learner)\n",
|
||||
"\n",
|
||||
" # CNTK: return trainer and loss as well\n",
|
||||
|
@ -681,7 +681,7 @@
|
|||
"D = 4 # input dimensionality\n",
|
||||
"H = 10 # number of hidden layer neurons\n",
|
||||
"\n",
|
||||
"observations = C.input_variable(shape=STATE_COUNT, data_type=np.float32, name=\"obs\")\n",
|
||||
"observations = C.input_variable(STATE_COUNT, np.float32, name=\"obs\")\n",
|
||||
"\n",
|
||||
"W1 = C.parameter(shape=(STATE_COUNT, H), init=C.glorot_uniform(), name=\"W1\")\n",
|
||||
"b1 = C.parameter(shape=H, name=\"b1\")\n",
|
||||
|
@ -710,13 +710,14 @@
|
|||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"input_y = C.input_variable(shape=1, data_type=np.float32, name=\"input_y\")\n",
|
||||
"advantages = C.input_variable(shape=1, data_type=np.float32, name=\"advt\")\n",
|
||||
"input_y = C.input_variable(1, np.float32, name=\"input_y\")\n",
|
||||
"advantages = C.input_variable(1, np.float32, name=\"advt\")\n",
|
||||
"\n",
|
||||
"loss = -C.reduce_mean(C.log(C.square(input_y - probability) + 1e-4) * advantages, axis=0, name='loss')\n",
|
||||
"\n",
|
||||
"lr = 0.001 \n",
|
||||
"sgd = C.sgd([W1, W2], lr)\n",
|
||||
"lr_schedule = learning_rate_schedule(lr, UnitType.minibatch) \n",
|
||||
"sgd = C.sgd([W1, W2], lr_schedule)\n",
|
||||
"\n",
|
||||
"gradBuffer = dict((var.name, np.zeros(shape=var.shape)) for var in loss.parameters if var.name in ['W1', 'W2', 'b1', 'b2'])\n",
|
||||
"\n",
|
||||
|
|
Загрузка…
Ссылка в новой задаче