代码拉取完成,页面将自动刷新
# %%
import torch
from torch import nn, Tensor, optim
from torch.autograd import Variable
from typing import (
TypeVar, Type, Union, Optional, Any,
List, Dict, Tuple, Callable, NamedTuple
)
import numpy as np
import random
import time
import os
import copy
import re
import logging
from concurrent.futures import ThreadPoolExecutor
from concurrent import futures
import itertools
from utils import Args, D, timeit
logger = logging.getLogger(__name__)
logging.basicConfig(
level=10, format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s')
a = [(1.4, 2), (3, 4), (5, 6)]
b = 4
_a = Tensor(a).t()
_b = Tensor(b)
_c = copy.deepcopy(_a)
_m = torch.stack((_a, _c))
print(_m)
# print(torch.stack((1,2,3,4)))
x = Tensor([1, 2])
print(torch.unsqueeze(x, 0))
print(torch.unsqueeze(x, 1))
# print(torch.unsqueeze(x, 1))
y = Tensor([
[1,2,3,4,5],
[6,7,8,9,10]
])
import torch.nn.functional as F
L=10
Y=F.pad(y,(0,L-y.shape[1]),"constant",value=0)
print(Y)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。