Model serialization with Shogun

The Shogun library can save model parameters in different file formats such as ASCII, JSON, XML, and HDF5. This library can't load model architectures from a file and is only able to save and load the weights of the exact model. But there is an exception for neural networks: the Shogun library can load a network structure from a JSON file. An example of this functionality is shown in the following example.

As in the previous example, we start by generating the training data:

const int32_t n = 1000;SGMatrix<float64_t> x_values(1, n);SGVector<float64_t> y_values(n);std::random_device rd;std::mt19937 re(rd());std::uniform_real_distribution<double> dist(-1.5, 1.5);// generate datafor (int32_t i = 0; i < n; ++i) ...

Get Hands-On Machine Learning with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.