Hi,
vector_to_parameters is not my own implementation. It is a PyTorch function.

  
      github.com
  
  
    pytorch/pytorch/blob/master/torch/nn/utils/convert_parameters.py 5
import torch


def parameters_to_vector(parameters):
    r"""Convert parameters to one vector

    Arguments:
        parameters (Iterable[Tensor]): an iterator of Tensors that are the
            parameters of a model.

    Returns:
        The parameters represented by a single vector
    """
    # Flag for the device where the parameter is located
    param_device = None

    vec = []
    for param in parameters:
        # Ensure the parameters are located in the same device
        param_device = _check_param_device(param, param_device)


  This file has been truncated. show original