Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The examples should be intendeed for begineers, not for testing internals. #320

Open
salvacarrion opened this issue Dec 3, 2021 · 0 comments
Assignees
Labels
Documentation Easy enhancement New feature or request help wanted Extra attention is needed

Comments

@salvacarrion
Copy link
Contributor

salvacarrion commented Dec 3, 2021

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Easy enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants