model.Model(self, input_size, output_size, fix_bias=False)

Abstract Model class

Attributes

Name Description
q0 Get initial hidden coordinates \(q_0=x_0U\)

Methods

Name Description
export_h5 Export the model to a HDF5 file
forward Forward propagation
grad Gradient of loss function
import_h5 Import the model from a HDF5 file
mse Mean squared error
mse_force Mean squared error with force
plot_basis Plot distribution of \(\phi\)
show_onebody Visualize one-dimensional cut.

export_h5

model.Model.export_h5(path)

Export the model to a HDF5 file

Parameters

Name Type Description Default
path str path to the HDF5 file required

Examples

import pompon
model = pompon.NNMPO(input_size=3, hidden_size=3, basis_size=5)
model.export_h5("/path/to/model.h5")

See Also

import_h5()

forward

model.Model.forward(x)

Forward propagation

Parameters

Name Type Description Default
x Array input tensor with shape \((D,n)\) where \(D\) is the batch size and \(n\) is the input size. required

Returns

Name Type Description
Array Array output tensor with shape \((D,1)\)

grad

model.Model.grad(
    x
    y
    *
    f=None
    basis_grad=True
    coordinator_grad=True
    lambda1=0.0
    mu1=1.0
    mu2=1.0
    wf=1.0
)

Gradient of loss function

Parameters

Name Type Description Default
x Array input tensor with shape \((D,n)\) where \(D\) is the batch size and \(n\) is the input size. required
y Array output tensor with shape \((D,1)\) required
f Array force tensor with shape \((D,n)\) None
basis_grad bool calculate \(w,b\) grad True
coordinator_grad bool calculate \(U\) grad True
wf float Weight \(w_f\) of force term in loss function. 1.0

Returns

Name Type Description
list[Parameter] list[Parameter]: list of parameters with gradients

import_h5

model.Model.import_h5(path)

Import the model from a HDF5 file

Parameters

Name Type Description Default
path str path to the HDF5 file required

Returns

Name Type Description
Model Model model instance

Examples

import pompon
model = pompon.NNMPO.import_h5("/path/to/model.h5")

See Also

export_h5()

mse

model.Model.mse(x, y)

Mean squared error

Parameters

Name Type Description Default
x Array input tensor with shape \((D,n)\) where \(D\) is the batch size and \(n\) is the input size. required
y Array output tensor with shape \((D,1)\) required

Returns

Name Type Description
float float mean squared error

mse_force

model.Model.mse_force(x, f)

Mean squared error with force

Parameters

Name Type Description Default
x Array input tensor with shape \((D,n)\) where \(D\) is the batch size and \(n\) is the input size. required
f Array force tensor with shape \((D,n)\) required

plot_basis

model.Model.plot_basis(x)

Plot distribution of \(\phi\)

Parameters

Name Type Description Default
x Array input tensor with shape \((D,n)\) where \(D\) is the batch size and \(n\) is the input size. required

Examples

Code
import numpy as np
import pompon
x = np.random.rand(10, 3)
model = pompon.NNMPO(input_size=3, hidden_size=3, basis_size=5,
                     activation="gauss", b_scale=1.0, w_scale=1.0)
model.plot_basis(x)

show_onebody

model.Model.show_onebody()

Visualize one-dimensional cut.

Examples

Code
import pompon
model = pompon.NNMPO(input_size=3, hidden_size=3, basis_size=5)
model.show_onebody()