Skip to content

Instantly share code, notes, and snippets.

@goldsborough
Created October 2, 2018 18:10
Show Gist options
  • Select an option

  • Save goldsborough/0be71b6ca777bb43cd26138faca1591f to your computer and use it in GitHub Desktop.

Select an option

Save goldsborough/0be71b6ca777bb43cd26138faca1591f to your computer and use it in GitHub Desktop.

Revisions

  1. goldsborough revised this gist Oct 2, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion minimal.cpp
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #include <torch/torch.h>

    torch::nn::Linear model(num_features, 1);
    torch::optim::SGD optimizer(model.parameters());
    torch::optim::SGD optimizer(model->parameters());
    auto data_loader = torch::data::data_loader(dataset);

    for (size_t epoch = 0; epoch < 10; ++epoch) {
  2. goldsborough renamed this gist Oct 2, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. goldsborough created this gist Oct 2, 2018.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #include <torch/torch.h>

    torch::nn::Linear model(num_features, 1);
    torch::optim::SGD optimizer(model.parameters());
    auto data_loader = torch::data::data_loader(dataset);

    for (size_t epoch = 0; epoch < 10; ++epoch) {
    for (auto batch : data_loader) {
    auto prediction = model->forward(batch.data);
    auto loss = loss_function(prediction, batch.target);
    loss.backward();
    optimizer.step();
    }
    }