#!/usr?bin/env/ python
# -*- coding:utf-8 -*-
import os
import torch
import numpy as np
np_data = np.arange(6).reshape((2,3))
torch_data = torch.from_numpy(np_data) # numpy类型转为tensor
tensor2array = torch_data.numpy() # tensor 数据类型转维numpy
print('\nnumpy',np_data,
'\ntorch',torch_data,
'\ntensor2array',tensor2array
)
numpy转Tensor
最新推荐文章于 2024-07-08 18:55:21 发布