-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
DocumentationEasyenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
The examples are filled with boilerplate code and conditionals that are hard to read (especially for beginners). We cannot forget that the examples are intended for beginners, so they should be short and simple. If we want to test things automatically, we have test_internals. The same goes for onnx/nn
Example from 1_mnist_mlp:
bool testing = false;
bool use_cpu = false;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--testing") == 0) testing = true;
else if (strcmp(argv[i], "--cpu") == 0) use_cpu = true;
}
// blablabla
if (use_cpu) {
cs = CS_CPU();
} else {
cs = CS_GPU({1},"low_mem"); // one GPU
// cs = CS_GPU({1,1},100); // two GPU with weight sync every 100 batches
// cs = CS_CPU();
// cs = CS_FPGA({1});
}
// blablabla
if (testing) {
std::string _range_ = "0:" + std::to_string(2 * batch_size);
Tensor* x_mini_train = x_train->select({_range_, ":"});
Tensor* y_mini_train = y_train->select({_range_, ":"});
Tensor* x_mini_test = x_test->select({_range_, ":"});
Tensor* y_mini_test = y_test->select({_range_, ":"});
delete x_train;
delete y_train;
delete x_test;
delete y_test;
x_train = x_mini_train;
y_train = y_mini_train;
x_test = x_mini_test;
y_test = y_mini_test;
}
Metadata
Metadata
Labels
DocumentationEasyenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed