EasyHybrid.jl
Documentation for EasyHybrid.jl.
EasyHybrid.EasyHybrid Module
EasyHybridEasyHybrid is a Julia package for hybrid machine learning models, combining neural networks and traditional statistical methods. It provides tools for data preprocessing, model training, and evaluation, making it easier to build and deploy hybrid models.
sourceEasyHybrid.BulkDensitySOC Type
BulkDensitySOC(NN, predictors, targets, oBD)A hybrid model with a neural network NN, predictors and one global parameter oBD.
EasyHybrid.BulkDensitySOC Method
BulkDensitySOC(NN, predictors, oBD)(ds_k)Hybrid model for bulk density based on the Federer (1993) paper http://dx.doi.org/10.1139/x93-131 plus SOC concentrations, density and coarse fraction
sourceEasyHybrid.HybridParams Type
HybridParams{M<:Function}A little parametric stub for “the params of function M.” All of your function‐based models become HybridParams{typeof(f)}.
EasyHybrid.LinearHM Type
LinearHM(NN, predictors, forcing, targets, β)A linear hybrid model with a neural network NN, predictors, forcing and targets terms.
EasyHybrid.LinearHM Method
LinearHM(NN, predictors, forcing, β)(ds_k)Model definition ŷ = α x + β
Apply the linear hybrid model to the input data ds_k (a KeyedArray with proper dimensions). The model uses the neural network NN to compute new α's based on the predictors and then computes ŷ using the forcing term x.
Returns:
A tuple containing the predicted values ŷ and a named tuple with the computed values of α and the state st.
Example:
using Lux
using EasyHybrid
using Random
using AxisKeys
ds_k = KeyedArray(rand(Float32, 3,4); data=[:a, :b, :c], sample=1:4)
m = Lux.Chain(Dense(2, 5), Dense(5, 1))
# Instantiate the model
# Note: The model is initialized with a neural network and the predictors and forcing terms
lh_model = LinearHM(m, (:a, :b), (:c,), 1.5f0)
rng = Random.default_rng()
Random.seed!(rng, 0)
ps, st = LuxCore.setup(rng, lh_model)
# Apply the model to the data
ŷ, αst = LuxCore.apply(lh_model, ds_k, ps, st)EasyHybrid.LoggingLoss Type
LoggingLossA structure to define a logging loss function for hybrid models.
Arguments
loss_types: A vector of loss specifications (Symbol, Function or Tuple)Symbol: predefined loss, e.g.
:mseFunction: custom loss function, e.g.
custom_lossTuple: function with args/kwargs:
(f, args): positional args, e.g.(weighted_loss, (0.5,))(f, kwargs): keyword args, e.g.(scaled_loss, (scale=2.0,))(f, args, kwargs): both, e.g.(complex_loss, (0.5,), (scale=2.0,))
training_loss: The loss specification to use during training (same format as above)agg: Function to aggregate losses across targets, e.g.sumormeantrain_mode: If true, usestraining_loss; otherwise usesloss_types.
Examples
# Simple predefined loss
logging = LoggingLoss(
loss_types=[:mse, :mae],
training_loss=:mse
)
# Custom loss function
custom_loss(ŷ, y) = mean(abs2, ŷ .- y)
logging = LoggingLoss(
loss_types=[:mse, custom_loss],
training_loss=custom_loss
)
# With arguments/kwargs
weighted_loss(ŷ, y, w) = w * mean(abs2, ŷ .- y)
scaled_loss(ŷ, y; scale=1.0) = scale * mean(abs2, ŷ .- y)
logging = LoggingLoss(
loss_types=[:mse, (weighted_loss, (0.5,)), (scaled_loss, (scale=2.0,))],
training_loss=(weighted_loss, (0.5,))
)EasyHybrid.RbQ10_2p Method
RbQ10_2p(NN, predictors, forcing, targets, Q10)(ds_k)Model definition ŷ = Rb(αᵢ(t)) * Q10^((T(t) - T_ref)/10)
ŷ (respiration rate) is computed as a function of the neural network output Rb(αᵢ(t)) and the temperature T(t) adjusted by the reference temperature T_ref (default 15°C) using the Q10 temperature sensitivity factor. ````
EasyHybrid.RespirationRbQ10 Type
RespirationRbQ10(NN, predictors, forcing, targets, Q10)A linear hybrid model with a neural network NN, predictors, targets and forcing terms.
EasyHybrid.RespirationRbQ10 Method
RespirationRbQ10(NN, predictors, forcing, targets, Q10)(ds_k)Model definition ŷ = Rb(αᵢ(t)) * Q10^((T(t) - T_ref)/10)
ŷ (respiration rate) is computed as a function of the neural network output Rb(αᵢ(t)) and the temperature T(t) adjusted by the reference temperature T_ref (default 15°C) using the Q10 temperature sensitivity factor. ````
EasyHybrid.Rs_components Type
Rs_components(NN, predictors, forcing, targets, Q10_het, Q10_root, Q10_myc)A linear hybrid model with a neural network NN, predictors, targets and forcing terms.
EasyHybrid.Rs_components Method
Rs_components(NN, predictors, forcing, targets, Q10)(ds_k)Model definition ŷ = Rb(αᵢ(t)) * Q10^((T(t) - T_ref)/10)
ŷ (respiration rate) is computed as a function of the neural network output Rb(αᵢ(t)) and the temperature T(t) adjusted by the reference temperature T_ref (default 15°C) using the Q10 temperature sensitivity factor. ````
EasyHybrid.WrappedTuples Type
WrappedTuples(vec::Vector{<:NamedTuple})Wraps a vector of named tuples to allow dot-access to each field as a vector.
sourceBase.Multimedia.display Method
Base.display(io::IO, parameter_container::ParameterContainer)Display a ParameterContainer containing parameter bounds in a formatted table.
This function creates a nicely formatted table showing parameter names as row labels and bound types (default, lower, upper) as column headers.
Arguments
io::IO: Output streamparameter_container::ParameterContainer: A ParameterContainer with parameter bounds (typically created bybuild_parameter_matrix)
Returns
- Displays a formatted table using PrettyTables.jl
Example
# Create parameter defaults and bounds
parameter_defaults_and_bounds = (
θ_s = (0.464f0, 0.302f0, 0.700f0),
α = (log(0.103f0), log(0.01f0), log(7.874f0)),
n = (log(3.163f0 - 1), log(1.100f0 - 1), log(20.000f0 - 1)),
)
# Build ParameterContainer and display
parameter_container = ParameterContainer(parameter_defaults_and_bounds)
display(parameter_container) # or just parameter_containerNotes
Requires PrettyTables.jl to be loaded
The table shows parameter names as row labels and bound types as column headers
Default alignment is right-aligned for all columns
EasyHybrid._apply_loss Method
_apply_loss(ŷ, y, y_nan, loss_spec)Helper function to apply the appropriate loss function based on the specification type.
Arguments
ŷ: Predictions for a single targety: Target values for a single targety_nan: NaN mask for a single targetloss_spec: Loss specification (Symbol, Function, or Tuple)
Returns
- Computed loss value
EasyHybrid.build_parameter_matrix Method
build_parameter_matrix(parameter_defaults_and_bounds::NamedTuple)Build a ComponentArray matrix from a NamedTuple containing parameter defaults and bounds.
This function converts a NamedTuple where each value is a tuple of (default, lower, upper) bounds into a ComponentArray with named axes for easy parameter management in hybrid models.
Arguments
parameter_defaults_and_bounds::NamedTuple: A NamedTuple where each key is a parameter name and each value is a tuple of (default, lower, upper) for that parameter.
Returns
ComponentArray: A 2D ComponentArray with:Row axis: Parameter names (from the NamedTuple keys)
Column axis: Bound types (:default, :lower, :upper)
Data: The parameter values organized in a matrix format
Example
# Define parameter defaults and bounds
parameter_defaults_and_bounds = (
θ_s = (0.464f0, 0.302f0, 0.700f0), # Saturated water content [cm³/cm³]
h_r = (1500.0f0, 1500.0f0, 1500.0f0), # Pressure head at residual water content [cm]
α = (log(0.103f0), log(0.01f0), log(7.874f0)), # Shape parameter [cm⁻¹]
n = (log(3.163f0 - 1), log(1.100f0 - 1), log(20.000f0 - 1)), # Shape parameter [-]
)
# Build the ComponentArray
parameter_matrix = build_parameter_matrix(parameter_defaults_and_bounds)
# Access specific parameter bounds
parameter_matrix.θ_s.default # Get default value for θ_s
parameter_matrix[:, :lower] # Get all lower bounds
parameter_matrix[:, :upper] # Get all upper boundsNotes
The function expects each value in the NamedTuple to be a tuple with exactly 3 elements
The order of bounds is always (default, lower, upper)
The resulting ComponentArray can be used for parameter optimization and constraint handling
EasyHybrid.build_parameters Method
build_parameters(parameters::NamedTuple, f::DataType) -> AbstractHybridModelConstructs a parameter container from a named tuple of parameter bounds and wraps it in a user-defined subtype of AbstractHybridModel.
Arguments
parameters::NamedTuple: Named tuple where each entry is a tuple of (default, lower, upper) bounds for a parameter.f::DataType: A constructor for a subtype ofAbstractHybridModelthat takes aParameterContaineras its argument.
Returns
- An instance of the user-defined
AbstractHybridModelsubtype containing the parameter container.
EasyHybrid.compute_bulk_density Method
compute_bulk_density(SOCconc, oBD, mBD)model for bulk density based on the Federer (1993) paper http://dx.doi.org/10.1139/x93-131 plus SOC concentrations, density and coarse fraction
sourceEasyHybrid.compute_loss Function
compute_loss(ŷ, y, y_nan, targets, training_loss, agg::Function)
compute_loss(ŷ, y, y_nan, targets, loss_types::Vector, agg::Function)Compute the loss for the given predictions and targets using the specified training loss (or vector of losses) type and aggregation function.
Arguments:
ŷ: Predicted values.y: Target values.y_nan: Mask for NaN values.targets: The targets for which the loss is computed.training_loss: The loss type to use during training, e.g.,:mse.loss_types::Vector: A vector of loss types to compute, e.g.,[:mse, :mae].agg::Function: The aggregation function to apply to the computed losses, e.g.,sumormean.
Returns a single loss value if training_loss is provided, or a NamedTuple of losses for each type in loss_types.
EasyHybrid.compute_loss Method
compute_loss(ŷ, y, y_nan, targets, loss_spec, agg::Function)
compute_loss(ŷ, y, y_nan, targets, loss_types::Vector, agg::Function)Compute loss values for predictions against targets using specified loss functions.
Arguments
ŷ: Model predictionsy: Target values (function or AbstractDimArray)y_nan: NaN mask (function or AbstractDimArray)targets: Target variable namesloss_spec: Single loss specification (Symbol, Function, or Tuple)loss_types: Vector of loss specificationsagg: Function to aggregate losses across targets
Returns
Single loss value when using
loss_specNamedTuple of losses when using
loss_types
EasyHybrid.constructNNModel Method
constructNNModel(predictors, targets; hidden_layers, activation, scale_nn_outputs)Main constructor: hidden_layers can be either • a Vector{Int} of sizes, or • a Chain of hidden-layer Dense blocks.
EasyHybrid.display_parameter_bounds Method
display_parameter_bounds(parameter_container::ParameterContainer; alignment=:r)Legacy function for displaying parameter bounds with custom alignment.
Arguments
parameter_container::ParameterContainer: A ParameterContainer with parameter boundsalignment: Alignment for table columns (default: right-aligned for all columns)
Returns
- Displays a formatted table using PrettyTables.jl
EasyHybrid.get_loss_value Method
get_loss_value(losses, loss_spec, agg)Extract loss value from losses based on the loss specification type.
Arguments
losses: NamedTuple containing loss valuesloss_spec: Loss specification (Symbol, Function or Tuple)agg: Aggregation function name as Symbol
Returns
- Loss value for the specified loss function
Examples
# Symbol case
val = get_loss_value(losses, :mse, :sum)
# Function case
custom_loss(ŷ, y) = mean(abs2, ŷ .- y)
val = get_loss_value(losses, custom_loss, :mean)
# Tuple case
weighted_loss(ŷ, y, w) = w * mean(abs2, ŷ .- y)
val = get_loss_value(losses, (weighted_loss, (0.5,)), :sum)EasyHybrid.get_prediction_target_names Method
get_prediction_target_names(hm)Utility function to extract predictor/forcing and target names from a hybrid model.
Arguments:
hm: The Hybrid Model
Returns a tuple of (predictors_forcing, targets) names.
sourceEasyHybrid.get_predictions_targets Method
get_predictions_targets(HM, x, (y_t, y_nan), ps, st, targets)Get predictions and targets from the hybrid model and return them along with the NaN mask.
Arguments
HM: The hybrid modelx: Input data(y_t, y_nan): Tuple of target values and NaN mask (functions or arrays)ps: Model parametersst: Model statetargets: Target variable names
Returns
ŷ: Model predictionsy: Target valuesy_nan: NaN maskst: Updated model state
EasyHybrid.initialize_plotting_observables Method
initialize_plotting_observables(init_ŷ_train, init_ŷ_val, y_train, y_val, l_init_train, l_init_val, training_loss, agg, monitor_names, target_names)Initialize plotting observables for training visualization if the Makie extension is loaded.
sourceEasyHybrid.load_timeseries_netcdf Method
load_timeseries_netcdf(path::AbstractString; timedim::AbstractString = "time") -> DataFrameReads a NetCDF file where all data variables are 1D over the specified timedim and returns a tidy DataFrame with one row per time step.
Only includes variables whose sole dimension is
timedim.Does not attempt to parse or convert time units; all columns are read as-is.
EasyHybrid.loss_fn Function
loss_fn(ŷ, y, y_nan, loss_type)Compute the loss for given predictions and targets using various loss specifications.
Arguments
ŷ: Predicted valuesy: Target valuesy_nan: Mask for NaN valuesloss_type: One of the following:Val(:rmse): Root Mean Square ErrorVal(:mse): Mean Square ErrorVal(:mae): Mean Absolute ErrorVal(:pearson): Pearson correlation coefficientVal(:r2): R-squared::Function: Custom loss function with signaturef(ŷ, y)::Tuple{Function, Tuple}: Custom loss with argsf(ŷ, y, args...)::Tuple{Function, NamedTuple}: Custom loss with kwargsf(ŷ, y; kwargs...)::Tuple{Function, Tuple, NamedTuple}: Custom loss with bothf(ŷ, y, args...; kwargs...)
Examples
# Predefined loss
loss = loss_fn(ŷ, y, y_nan, Val(:mse))
# Custom loss function
custom_loss(ŷ, y) = mean(abs2, ŷ .- y)
loss = loss_fn(ŷ, y, y_nan, custom_loss)
# With positional arguments
weighted_loss(ŷ, y, w) = w * mean(abs2, ŷ .- y)
loss = loss_fn(ŷ, y, y_nan, (weighted_loss, (0.5,)))
# With keyword arguments
scaled_loss(ŷ, y; scale=1.0) = scale * mean(abs2, ŷ .- y)
loss = loss_fn(ŷ, y, y_nan, (scaled_loss, (scale=2.0,)))
# With both args and kwargs
complex_loss(ŷ, y, w; scale=1.0) = scale * w * mean(abs2, ŷ .- y)
loss = loss_fn(ŷ, y, y_nan, (complex_loss, (0.5,), (scale=2.0,)))You can define additional predefined loss functions by adding more methods:
import EasyHybrid: loss_fn
function EasyHybrid.loss_fn(ŷ, y, y_nan, ::Val{:nse})
return 1 - sum((ŷ[y_nan] .- y[y_nan]).^2) / sum((y[y_nan] .- mean(y[y_nan])).^2)
endEasyHybrid.lossfn Method
lossfn(HM, x, (y_t, y_nan), ps, st, logging::LoggingLoss)Main loss function for hybrid models that handles both training and evaluation modes.
Arguments
HM: The hybrid model (AbstractLuxContainerLayer or specific model type)x: Input data for the model(y_t, y_nan): Tuple containing target values and NaN mask functions/arraysps: Model parametersst: Model statelogging: LoggingLoss configuration
Returns
In training mode (
logging.train_mode = true):(loss_value, st): Single loss value and updated state
In evaluation mode (
logging.train_mode = false):(loss_values, st, ŷ): NamedTuple of losses, state and predictions
EasyHybrid.make_folds Method
make_folds(df::DataFrame; k::Int=5, shuffle=true) -> Vector{Int}Assigns each observation in the DataFrame df to one of k folds for cross-validation.
Arguments
df::DataFrame: The input DataFrame whose rows are to be split into folds.k::Int=5: Number of folds to create.shuffle=true: Whether to shuffle the data before assigning folds.
Returns
folds::Vector{Int}: A vector of lengthnrow(df)where each entry is an integer in1:kindicating the fold assignment for that observation.
EasyHybrid.prepare_data Function
prepare_data(hm, data::DataFrame)
prepare_data(hm, data::KeyedArray)
prepare_data(hm, data::AbstractDimArray)
prepare_data(hm, data::Tuple)Prepare data for training by extracting predictor/forcing and target variables based on the hybrid model's configuration.
Arguments:
hm: The Hybrid Modeldata: The input data, which can be a DataFrame, KeyedArray, or DimensionalData array.
Returns:
If
datais a DataFrame, KeyedArray returns a tuple of (predictors_forcing, targets) as KeyedArrays.If
datais an AbstractDimArray returns a tuple of (predictors_forcing, targets) of AbstractDimArrays.If
datais already a Tuple, it is returned as-is.
Method
prepare_hidden_chain(hidden_layers, in_dim, out_dim; activation, input_batchnorm=false)Construct a neural network Chain for use in NN models.
Arguments
hidden_layers::Union{Vector{Int}, Chain}:If a
Vector{Int}, specifies the sizes of each hidden layer. For example,[32, 16]creates two hidden layers with 32 and 16 units, respectively.If a
Chain, the user provides a pre-built chain of hidden layers (excluding input/output layers).
in_dim::Int: Number of input features (input dimension).out_dim::Int: Number of output features (output dimension).activation: Activation function to use in hidden layers (default:tanh).input_batchnorm::Bool: Iftrue, applies aBatchNormlayer to the input (default:false).
Returns
- A
Chainobject representing the full neural network, with the following structure:Optional input batch normalization (if
input_batchnorm=true)Input layer:
Dense(in_dim, h₁, activation)whereh₁is the first hidden sizeHidden layers: either user-supplied
Chainor constructed fromhidden_layersOutput layer:
Dense(hₖ, out_dim)wherehₖis the last hidden size
where h₁ is the first hidden size and hₖ the last.
EasyHybrid.scale_single_param Method
scale_single_param(name, raw_val, parameters)Scale a single parameter using the sigmoid scaling function.
sourceEasyHybrid.scale_single_param_minmax Method
scale_single_param_minmax(name, hm::AbstractHybridModel)Scale a single parameter using the minmax scaling function.
sourceEasyHybrid.split_data Function
split_data(data, hybridModel; split_by_id=nothing, shuffleobs=false, split_data_at=0.8, kwargs...)
split_data(data::Union{DataFrame, KeyedArray}, hybridModel; split_by_id=nothing, shuffleobs=false, split_data_at=0.8, folds=nothing, val_fold=nothing, kwargs...)
split_data(data::AbstractDimArray, hybridModel; split_by_id=nothing, shuffleobs=false, split_data_at=0.8, kwargs...)
split_data(data::Tuple, hybridModel; split_by_id=nothing, shuffleobs=false, split_data_at=0.8, kwargs...)
split_data(data::Tuple{Tuple, Tuple}, hybridModel; kwargs...)Split data into training and validation sets, either randomly, by grouping by ID, or using external fold assignments.
Arguments:
data: The data to split, which can be a DataFrame, KeyedArray, AbstractDimArray, or TuplehybridModel: The hybrid model object used for data preparationsplit_by_id=nothing: Eithernothingfor random splitting, aSymbolfor column-based splitting, or anAbstractVectorfor custom ID-based splittingshuffleobs=false: Whether to shuffle observations during splittingsplit_data_at=0.8: Ratio of data to use for trainingfolds: Vector or column name of fold assignments (1..k), one per sample/column for k-fold cross-validationval_fold: The validation fold to use whenfoldsis provided
Behavior:
For DataFrame/KeyedArray: Supports random splitting, ID-based splitting, and external fold assignments
For AbstractDimArray/Tuple: Random splitting only after data preparation
For pre-split Tuple{Tuple, Tuple}: Returns input unchanged
Returns:
((x_train, y_train), (x_val, y_val)): Tuple containing training and validation data pairs
EasyHybrid.split_data Method
split_data(df::DataFrame, target, xvars, seqID; f=0.8, batchsize=32, shuffle=true, partial=true)
sourceEasyHybrid.split_data Method
split_data(df::DataFrame, target, xvars; f=0.8, batchsize=32, shuffle=true, partial=true)
sourceEasyHybrid.to_keyedArray Function
tokeyedArray(dfg::Union{Vector,GroupedDataFrame{DataFrame}}, vars=All())
sourceEasyHybrid.train Method
train(hybridModel, data, save_ps; nepochs=200, batchsize=10, opt=Adam(0.01), patience=typemax(Int),
file_name=nothing, loss_types=[:mse, :r2], training_loss=:mse, agg=sum, train_from=nothing,
random_seed=161803, yscale=log10, monitor_names=[], return_model=:best,
plotting=true, show_progress=true, hybrid_name=randstring(10), kwargs...)Train a hybrid model using the provided data and save the training process to a file in JLD2 format. Default output file is trained_model.jld2 at the current working directory under output_tmp.
Arguments:
hybridModel: The hybrid model to be trained.data: The training data, either a single DataFrame, a single KeyedArray, or a tuple of KeyedArrays.save_ps: A tuple of physical parameters to save during training.
Core Training Parameters:
nepochs: Number of training epochs (default: 200).batchsize: Size of the training batches (default: 10).opt: The optimizer to use for training (default: Adam(0.01)).patience: The number of epochs to wait before early stopping (default:typemax(Int)-> no early stopping).
Loss and Evaluation:
training_loss: The loss type to use during training (default::mse).loss_types: A vector of loss types to compute during training (default:[:mse, :r2]).agg: The aggregation function to apply to the computed losses (default:sum).
Data Handling (passed via kwargs):
shuffleobs: Whether to shuffle the training data (default: false).split_by_id: Column name or function to split data by ID (default: nothing -> no ID-based splitting).split_data_at: Fraction of data to use for training when splitting (default: 0.8).folds: Vector or column name of fold assignments (1..k), one per sample/column for k-fold cross-validation (default: nothing).val_fold: The validation fold to use whenfoldsis provided (default: nothing).
Training State and Reproducibility:
train_from: A tuple of physical parameters and state to start training from or an output oftrain(default: nothing -> new training).random_seed: The random seed to use for training (default: 161803).
Output and Monitoring:
file_name: The name of the file to save the training process (default: nothing -> "trained_model.jld2").hybrid_name: Name identifier for the hybrid model (default: randomly generated 10-character string).return_model: The model to return::bestfor the best model,:finalfor the final model (default::best).monitor_names: A vector of monitor names to track during training (default:[]).folder_to_save: Additional folder name string to append to output path (default: "").
Visualization and UI:
plotting: Whether to generate plots during training (default: true).show_progress: Whether to show progress bars during training (default: true).yscale: The scale to apply to the y-axis for plotting (default:log10).
EasyHybrid.unpack_keyedarray Method
unpack_keyedarray(ka::KeyedArray, variable::Symbol) Extract a single variable from a KeyedArray and return it as a vector.
Arguments:
ka: The KeyedArray to unpackvariable: Symbol representing the variable to extract
Returns:
- Vector containing the variable data
Example:
# Extract just SW_IN from a KeyedArray
sw_in = unpack_keyedarray(ds_keyed, :SW_IN)EasyHybrid.unpack_keyedarray Method
unpack_keyedarray(ka::KeyedArray, variables::Vector{Symbol}) Extract specified variables from a KeyedArray and return them as a NamedTuple of vectors.
Arguments:
ka: The KeyedArray to unpackvariables: Vector of symbols representing the variables to extract
Returns:
- NamedTuple with variable names as keys and vectors as values
Example:
# Extract SW_IN and TA from a KeyedArray
data = unpack_keyedarray(ds_keyed, [:SW_IN, :TA])
sw_in = data.SW_IN
ta = data.TAEasyHybrid.unpack_keyedarray Method
unpack_keyedarray(ka::KeyedArray) Extract all variables from a KeyedArray and return them as a NamedTuple of vectors.
Arguments:
ka: The KeyedArray to unpack
Returns:
- NamedTuple with all variable names as keys and vectors as values
Example:
# Extract all variables from a KeyedArray
data = unpack_keyedarray(ds_keyed)
# Access individual variables
sw_in = data.SW_IN
ta = data.TA
nee = data.NEEEasyHybrid.@hybrid Macro
@hybrid ModelName α β γMacro to define hybrid model structs with arbitrary numbers of physical parameters.
This defines a struct with:
Default fields:
NN(neural network),predictors,forcing,targets.Additional physical parameters, i.e.,
α β γ.
Examples
@hybrid MyModel α β γ
@hybrid FluidModel (:viscosity, :density)
@hybrid SimpleModel :a :b