Commit 671be670 authored by Cianciosa, Mark's avatar Cianciosa, Mark
Browse files

Add custom pytorch models.

parent 5d596cb3
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -15,6 +15,18 @@ ml_model mlce_init_keras(const char *filename) {
    return reinterpret_cast<ml_model> (new ml_embedder::keras(std::string(filename)));
}

//------------------------------------------------------------------------------
///  @brief Initalize a custom pytorch model.
///
///  @param[in] weights_filename Path to the model weights.
///  @param[in] config_filename  Path to the model config.
//------------------------------------------------------------------------------
ml_model mlce_init_custom_pytorch(const char *weights_filename,
                                  const char *config_filename) {
    return reinterpret_cast<ml_model> (new ml_embedder::custom_pytorch(std::string(weights_filename),
                                                                       std::string(config_filename)));
}

//------------------------------------------------------------------------------
///  @brief Finalize a model.
///
+9 −0
Original line number Diff line number Diff line
@@ -24,6 +24,15 @@ extern "C" {
//------------------------------------------------------------------------------
    ml_model mlce_init_keras(const char *filename);

//------------------------------------------------------------------------------
///  @brief Initalize a custom pytorch model.
///
///  @param[in] weights_filename Path to the model weights.
///  @param[in] config_filename  Path to the model config.
//------------------------------------------------------------------------------
    ml_model mlce_init_custom_pytorch(const char *weights_filename,
                                      const char *config_filename);

//------------------------------------------------------------------------------
///  @brief Finalize a model.
///
+77 −0
Original line number Diff line number Diff line
{
  "model_name": "MyModel",
  "layers": [
    {
      "name": "dense1",
      "class_name": "Dense",
      "units": 15,
      "activation": "relu",
      "use_bias": true
    },
    {
      "name": "dense2",
      "class_name": "Dense",
      "units": 25,
      "activation": "relu",
      "use_bias": true
    },
    {
      "name": "dense3",
      "class_name": "Dense",
      "units": 15,
      "activation": "relu",
      "use_bias": true
    },
    {
      "name": "dense4",
      "class_name": "Dense",
      "units": 1,
      "activation": "softplus",
      "use_bias": true
    }
  ],
  "weights": {
    "dense1": {
      "kernel": null,
      "bias": null
    },
    "dense2": {
      "kernel": null,
      "bias": null
    },
    "dense3": {
      "kernel": null,
      "bias": null
    },
    "dense4": {
      "kernel": null,
      "bias": null
    }
  },
  "forward_logic": [
    {
      "operation": "slice",
      "axis": 1,
      "start": 0,
      "end": -1,
      "input": "inputs",
      "output": "x"
    },
    {
      "operation": "dense_layers",
      "sequence": [
        "dense1",
        "dense2",
        "dense3",
        "dense4"
      ],
      "input": "x",
      "output": "x"
    },
    {
      "operation": "scale",
      "formula": "x / (1/39 / inputs[:, -1])",
      "output": "x"
    }
  ]
}
 No newline at end of file
+20.5 KiB

File added.

No diff preview for this file type.

Loading