Source code for gluonts.torch.support.util

# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
from typing import Optional

import torch


[docs]def copy_parameters( net_source: torch.nn.Module, net_dest: torch.nn.Module, strict: Optional[bool] = True, ) -> None: """ Copies parameters from one network to another. Parameters ---------- net_source Input network. net_dest Output network. strict: whether to strictly enforce that the keys in :attr:`state_dict` match the keys returned by this module's :meth:`~torch.nn.Module.state_dict` function. Default: ``True`` """ net_dest.load_state_dict(net_source.state_dict(), strict=strict)