/// <summary> /// Retrieves the weights of the model /// </summary> /// <returns>A flat list of Numpy arrays</returns> public List <NDarray> GetWeights() { var args = new Dictionary <string, object>(); var pyWeights = PyInstance.get_weights(); List <NDarray> weights = new List <NDarray>(); foreach (PyObject weightsArray in pyWeights) { var n = np.array(new NDarray(weightsArray)); weights.Add(n); } return(weights); }
/// <summary> /// Summaries the specified line length. /// </summary> /// <param name="line_length">Length of the line.</param> /// <param name="positions">The positions.</param> public void Summary(int?line_length = null, float[] positions = null) { PyInstance.summary(line_length: line_length, positions: positions); }
/// <summary> /// Loads the weight to the model from a file. /// </summary> /// <param name="path">The path of of the weight file.</param> public void LoadWeight(string path) { PyInstance.load_weights(path); }
/// <summary> /// Save the model to h5 file /// </summary> /// <param name="path">The path with filename eg: model.h5.</param> public void Save(string filepath, bool overwrite = true, bool include_optimizer = true) { PyInstance.save(filepath: filepath, overwrite: overwrite, include_optimizer: include_optimizer); }
/// <summary> /// Saves the weight of the trained model to a file. /// </summary> /// <param name="path">The path of the weight to save.</param> public void SaveWeight(string path) { PyInstance.save_weights(path); }
/// <summary> /// Converts the model to json. /// </summary> /// <returns></returns> public string ToJson() { return(PyInstance.to_json().ToString()); }
/// <summary> /// Save the model to h5 file /// </summary> /// <param name="path">The path with filename eg: model.h5.</param> public void Save(string path) { PyInstance.save(path); }
/// <summary> /// You can also simply add layers via the .Add() method /// </summary> /// <param name="layer">The layer.</param> public void Add(BaseLayer layer) { PyInstance.add(layer: layer.PyInstance); }