aphin.layers package
Submodules
aphin.layers.descriptor_ph_layer module
TensorFlow layers for identification of dynamical systems e.g. LTI systems (LTILayer), port-Hamiltonian systems (PHLayer), … intended for standalone use or the use in the latent space of an autoencoder. All layers approximate the right-hand side of the ODE given states z(t), inputs u(t) and parameters mu and should be trained using reference values of the states, inputs, parameters and the left-hand side of the ODE which is assumed to depend only on the time derivative of the states.
- class aphin.layers.descriptor_ph_layer.DescriptorPHLayer(*args, **kwargs)[source]
Bases:
PHLayer
Layer for port-Hamiltonian (pH) approximation with a descriptive matrix of the time derivative of the latent variable E * z’(t) = (J - R) * z(t) + B * u(t) with J skew-symmetric, R symmetric positive definite, and E symmetric.
- property E
Get the symmetric matrix E.
- Returns:
Symmetric matrix E.
- Return type:
tf.Tensor
- class aphin.layers.descriptor_ph_layer.DescriptorPHQLayer(*args, **kwargs)[source]
Bases:
PHQLayer
Layer for port-Hamiltonian (pH) approximation with a descriptive matrix of the time derivative of the latent variable E * z’(t) = (J - R) * Q * z(t) + B * u(t) with J skew-symmetric, R symmetric positive definite, Q symmetric positive definite, and E symmetric. This is a generalization of DescriptorPHLayer.
- property E
Get the symmetric matrix E.
- Returns:
Symmetric matrix E.
- Return type:
tf.Tensor
aphin.layers.lti_layer module
TensorFlow layers for identification of dynamical systems e.g. LTI systems (LTILayer), port-Hamiltonian systems (PHLayer), … intended for standalone use or the use in the latent space of an autoencoder. All layers approximate the right-hand side of the ODE given states z(t), inputs u(t) and parameters mu and should be trained using reference values of the states, inputs, parameters and the left-hand side of the ODE which is assumed to depend only on the time derivative of the states.
- class aphin.layers.lti_layer.LTILayer(*args, **kwargs)[source]
Bases:
SystemLayer
Layer for LTI approximation of the time derivative of the latent variable z’(t) = A * z(t) + B * u(t) with A = J - R, J skew. sym., R sym. The system matrix is decomposed into skew-symmetric J and symmetric parts R for conformity with pH layers
- property B
Get the (full) input matrix B.
- Returns:
Input matrix B.
- Return type:
tf.Tensor
- property J
Get the skew-symmetric matrix J.
- Returns:
Skew-symmetric matrix J.
- Return type:
tf.Tensor
- property R
Get the symmetric matrix R.
- Returns:
Symmetric matrix R.
- Return type:
tf.Tensor
- call(z, u=None, mu=None, training=False)[source]
Evaluate right-hand side of the ODE system z’(t) = f(z, u, mu) for inputs (z, u, mu).
- Parameters:
z (array-like) – System states with shape (n_t * n_s, n).
u (array-like, optional) – System inputs with shape (n_t * n_s, n_u), by default None.
mu (array-like, optional) – Parameters, by default None.
training (bool, optional) – Whether the call is in training mode, by default False.
- Returns:
Approximation of z’(t).
- Return type:
tf.Tensor
- property dof_split
Split of the internal degrees of freedom into J, R, B.
- Returns:
Tuple containing the split of degrees of freedom.
- Return type:
tuple
- get_parameter_dependent_weights(mu)[source]
In case of parameter dependent weights, get the weights for the given parameters.
- Parameters:
mu (array-like) – Parameters.
- Returns:
Tuple containing dof_J, dof_R, dof_B, and dof_Q.
- Return type:
tuple
- get_system_matrices(mu=None, n_t=None)[source]
Return matrices in the format (n_sim, r, r).
- Parameters:
mu (array-like, optional) – Parameters, by default None.
n_t (int, optional) – Number of time steps, required if mu is not None, by default None.
- Returns:
Tuple containing matrices J, R, and B.
- Return type:
tuple
- init_parameter_dependent_weights()[source]
Initialize trainable variables that depend on parameters (mu).
- property n_matrices_dofs
Number of trainable variables for the matrices.
- Returns:
Number of trainable variables.
- Return type:
int
aphin.layers.ph_layer module
TensorFlow layers for identification of dynamical systems e.g. LTI systems (LTILayer), port-Hamiltonian systems (PHLayer), … intended for standalone use or the use in the latent space of an autoencoder. All layers approximate the right-hand side of the ODE given states z(t), inputs u(t) and parameters mu and should be trained using reference values of the states, inputs, parameters and the left-hand side of the ODE which is assumed to depend only on the time derivative of the states.
- class aphin.layers.ph_layer.PHLayer(*args, **kwargs)[source]
Bases:
LTILayer
Layer for port-Hamiltonian (pH) approximation of the time derivative of the latent variable z’(t) = (J - R) * z(t) + B * u(t) with J skew-symmetric and R symmetric positive definite.
- property R
Get the symmetric positive definite matrix R.
- Returns:
Symmetric positive definite matrix R.
- Return type:
tf.Tensor
aphin.layers.phq_layer module
TensorFlow layers for identification of dynamical systems e.g. LTI systems (LTILayer), port-Hamiltonian systems (PHLayer), … intended for standalone use or the use in the latent space of an autoencoder. All layers approximate the right-hand side of the ODE given states z(t), inputs u(t) and parameters mu and should be trained using reference values of the states, inputs, parameters and the left-hand side of the ODE which is assumed to depend only on the time derivative of the states.
- class aphin.layers.phq_layer.PHQLayer(*args, **kwargs)[source]
Bases:
PHLayer
Layer for port-Hamiltonian (pH) approximation of the time derivative of the latent variable z’(t) = (J - R) * Q * z(t) + B * u(t) with J skew-symmetric, R symmetric positive definite, and Q symmetric positive definite. This is a generalization of PHLayer.
- property Q
Get the symmetric positive definite matrix Q.
- Returns:
Symmetric positive definite matrix Q.
- Return type:
tf.Tensor
- call(z, u, mu=None, training=False)[source]
Evaluate right-hand side of the ODE system z’(t) = f(z, u, mu) for inputs (z, u, mu).
- Parameters:
z (array-like) – System states with shape (n_t * n_s, n).
u (array-like, optional) – System inputs with shape (n_t * n_s, n_u), by default None.
mu (array-like, optional) – Parameters, by default None.
training (bool, optional) – Whether the call is in training mode, by default False.
- Returns:
Approximation of z’(t).
- Return type:
tf.Tensor
- property dof_split
Split of the internal degrees of freedom into J, R, B, and Q.
- Returns:
Tuple containing the split of degrees of freedom.
- Return type:
tuple
- get_system_matrices(mu=None, n_t=None)[source]
Return matrices in the format (n_sim, r, r).
- Parameters:
mu (array-like, optional) – Parameters, by default None.
n_t (int, optional) – Number of time steps, required if mu is not None, by default None.
- Returns:
Tuple containing matrices J, R, B, and Q.
- Return type:
tuple
- property n_matrices_dofs
Number of trainable variables for the matrices.
- Returns:
Number of trainable variables.
- Return type:
int
aphin.layers.system_layer module
TensorFlow layers for identification of dynamical systems e.g. LTI systems (LTILayer), port-Hamiltonian systems (PHLayer), … intended for standalone use or the use in the latent space of an autoencoder. All layers approximate the right-hand side of the ODE given states z(t), inputs u(t) and parameters mu and should be trained using reference values of the states, inputs, parameters and the left-hand side of the ODE which is assumed to depend only on the time derivative of the states.
- class aphin.layers.system_layer.SystemLayer(*args, **kwargs)[source]
Bases:
Layer
Layer for identification of an abstract system z’(t) = f(z, u, mu).
This layer approximates the right-hand side of the ODE given states z(t), inputs u(t), and parameters mu. It is intended for standalone use or for use in the latent space of an autoencoder.
- abstract call(z, u=None, mu=None, training=False)[source]
Evaluate rhs of the ODE z’(t) = f(z, u, mu) for inputs (z, u, mu).
- Parameters:
z (array-like) – State variables.
u (array-like, optional) – Input variables, by default None.
mu (array-like, optional) – Parameter variables, by default None.
training (bool, optional) – Whether the call is in training mode, by default False.
- Returns:
Approximation of z’(t).
- Return type:
tf.Tensor