GithubHelp home page GithubHelp logo

Comments (1)

chavicoski avatar chavicoski commented on June 10, 2024

Hi,

If you want to use the model with a "low_mem" configuration, you should say it in the constructor of the CompServ. The argument "mem" of the ONNX import function is not valid for doing that, and we will probably remove this argument in the future.

You can see the example using the CompServ here:

#include <iostream>

#include "eddl/apis/eddl.h"
#include "eddl/serialization/onnx/eddl_onnx.h"

using namespace eddl;

int main(int argc, char **argv) {
    auto resnet101 = import_net_from_onnx_file("resnet101.onnx", { 3, 224, 224 }, 0);
    auto resnet101_low_mem = import_net_from_onnx_file("resnet101.onnx", { 3, 224, 224 }, 0); // <- Use 0

    auto conv = dynamic_cast<LConv*>(resnet101->layers[1]);
    auto conv_low_mem = dynamic_cast<LConv*>(resnet101_low_mem->layers[1]);

    build(resnet101,
          adam(),
          {"softmax_cross_entropy"},
          {"categorical_accuracy"},
          CS_CPU(-1, "full_mem")); // <- "full_mem"

    build(resnet101_low_mem,
          adam(),
          {"softmax_cross_entropy"},
          {"categorical_accuracy"},
          CS_CPU(-1, "low_mem")); // <- "low_mem"

    eddl_free(conv->cd->ptrI);
    cout << "Conv ptrI freed" << endl;
    eddl_free(conv_low_mem->cd->ptrI);  // Now the program doesn't break
    cout << "Conv_low_mem ptrI freed" << endl;

    return EXIT_SUCCESS;
}

And regarding your last question, you can import the model and then use any configuration that you want, it just changes the amount of memory reserved for the operations, but the results should be the same.

from eddl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.