Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions example/cifar10/cifar10.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def SimpleFactory(data, ch_1x1, ch_3x3):

get_data.GetCifar10()
batch_size = 128
num_round = 3
num_round = 10
num_gpus = 1

train_dataiter = mx.io.ImageRecordIter(
Expand All @@ -120,22 +120,15 @@ def SimpleFactory(data, ch_1x1, ch_3x3):
batch_size=batch_size,
preprocess_threads=1)

logging.basicConfig(level=logging.DEBUG)

gpus = [mx.gpu(i) for i in range(num_gpus)]
# Use create functional style to train a model
model = mx.model.FeedForward.create(
symbol=softmax, ctx=gpus,
X=train_dataiter, eval_data=test_dataiter,
num_round=num_round,
learning_rate=0.05, momentum=0.9, wd=0.00001)

# Alternatively, you can use sklearn-style two-step API, as follows
"""
model = mx.model.FeedForward(
symbol=softmax, ctx=gpus,
num_round=num_round,
learning_rate=0.05, momentum=0.9, wd=0.00001)

model.fit(X=train_dataiter, eval_data=test_dataiter)
"""
def test_cifar():
logging.basicConfig(level=logging.DEBUG)
total_batch = 50000 / batch_size + 1
gpus = [mx.gpu(i) for i in range(num_gpus)]
model = mx.model.FeedForward(ctx=gpus, symbol=softmax, num_round = num_round,
learning_rate=0.05, momentum=0.9, wd=0.00001,
lr_scheduler=mx.misc.FactorScheduler(2))
model.fit(X=train_dataiter, eval_data=test_dataiter,
epoch_end_callback=mx.callback.Speedometer(batch_size))

if __name__ == "__main__":
test_cifar()
2 changes: 1 addition & 1 deletion example/notebooks/alexnet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
}
],
"source": [
"mx.viz.plot_network(\"AlexNet\", softmax)"
"mx.viz.plot_network(softmax)"
]
},
{
Expand Down
Loading