Skip to content

PyTorch weights

stegobox.io.nnmodel.read(filepath)

Read a neural network model in format of collections.OrderedDict from a pth file.

Parameters:

Name Type Description Default
filepath str

The name or path of the pth file.

required

Returns:

Type Description
OrderedDict

The neural networks model in format of collections.OrderedDict.

Source code in stegobox/io/nnmodel.py
def read(filepath: str) -> collections.OrderedDict:
    """Read a neural network model in format of collections.OrderedDict from a pth file.

    Args:
        filepath: The name or path of the pth file.

    Returns:
        The neural networks model in format of collections.OrderedDict.
    """
    return torch.load(filepath)

stegobox.io.nnmodel.write(model, filepath)

Save a neural network model in format of collections.OrderedDict to a pth file.

Parameters:

Name Type Description Default
model OrderedDict

The neural networks model in format of collections.OrderedDict.

required
filepath str

The name or path of the pth file.

required
Source code in stegobox/io/nnmodel.py
def write(model: collections.OrderedDict, filepath: str) -> None:
    """Save a neural network model in format of collections.OrderedDict to a pth file.

    Args:
        model: The neural networks model in format of collections.OrderedDict.
        filepath: The name or path of the pth file.
    """

    torch.save(model, filepath)