utils

utils

Functions

Name Description
export_mpo_to_itensor Export MPO to ITensor format
train_test_split Split the dataset into training and test sets

export_mpo_to_itensor

utils.export_mpo_to_itensor(mpo, path, name)

Export MPO to ITensor format

Parameters

Name Type Description Default
mpo list[np.array | Array] MPO required
path str path to the output file. For example, “/path/to/mpo.h5” required
name str name of the MPO. For example, “V” required

Returns

Name Type Description
str str path to the filled mpo file (e.g. “/path/to/mpo_filled.h5”)

Examples

See also docs/notebook/nnmpo_to_itensor_mpo.ipynb and ITensors.jl

train_test_split

utils.train_test_split(
    *arrays
    test_size=None
    train_size=None
    random_state=None
    shuffle=True
)

Split the dataset into training and test sets

Almost same interface as sklearn.model_selection.train_test_split

Parameters

Name Type Description Default
*arrays (np.array, Array) arrays to be split ()
test_size float the proportion of the dataset to include in the test split. Defaults to None. None
train_size float the proportion of the dataset to include in the train split. Defaults to None. None
random_state int random seed. Defaults to None. None
shuffle bool whether to shuffle the data before splitting. Defaults to True. True

Returns

Name Type Description
list[np.ndarray] list[np.ndarray]: x_train, x_test, y_train, y_test, …

Examples

>>> x_train, x_test, y_train, y_test, f_train, f_test = train_test_split(
...     x, y, f, test_size=0.2
... )