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

saving a model #30

Closed
kiranmaya opened this issue Sep 23, 2019 · 2 comments
Closed

saving a model #30

kiranmaya opened this issue Sep 23, 2019 · 2 comments

Comments

@kiranmaya
Copy link

how to save a engine graph model and loading ?

@1knueller
Copy link

You can serialize the model and save that into a file and load load the model from it.
I usggest you check through the tutorials.

// LOAD
const int HIDDEN_LAYER_SIZE = 1024, BATCH_SIZE = 64, TRAINING_ITERATIONS = 20;
const float LEARNING_RATE = 0.05f;
var engine = graph.CreateTrainingEngine(trainingData, LEARNING_RATE, BATCH_SIZE);
    Console.WriteLine("Loading existing model from: " + outputModelPath);
    using (var file = new FileStream(outputModelPath, FileMode.Open, FileAccess.Read)) {
        var model = Serializer.Deserialize<GraphModel>(file);
        engine = graph.CreateTrainingEngine(trainingData, model.Graph, LEARNING_RATE, BATCH_SIZE);
    }

// train the network for twenty iterations, saving the model on each improvement
Models.ExecutionGraph bestGraph = null;
engine.Train(TRAINING_ITERATIONS, testData, errorMetric, model => {
    bestGraph = model.Graph;
    if (!String.IsNullOrWhiteSpace(outputModelPath)) {
        using (var file = new FileStream(outputModelPath, FileMode.Create, FileAccess.Write)) {
            Serializer.Serialize(file, model);
        }
    }
});

These codeblocks are from:

http://www.jackdermody.net/brightwire/article/Convolutional_Neural_Networks

@kiranmaya
Copy link
Author

thanks ,without reading all tutorials,i searched for "save" in api ,now i understand .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants