![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch
黑白德芙Sani
这个作者很懒,什么都没留下…
展开
-
pytorch中的部分张量操作:输出满足条件的张量与合并多维张量
import torcha = torch.rand((6,1024,9))# print(a)# print(a[1, :])# 暴力法输出满足条件的张量,但时空复杂度均高for i in range(0,6): aa = a[i, :, 0] for j in range(len(aa)): if aa[j]>0.5: ...原创 2019-08-28 13:52:17 · 1374 阅读 · 0 评论 -
torch 代码片段:从3d-tensor中选择满足条件的行数据并重新组合
从3d-tensor中选择满足条件的行数据, 重新组合成原始维度的3d-tensor, 1维度产生数量变化# 获取预测中二分类标签为1的所有点,组成临时点集# 逐元素比较预测标签与1是否相等,相等输出同行(点)的其余信息# 从3d-tensor中选择满足条件的行数据, 重新组合成原始维度的3d-tensor, 1维度产生数量变化input_pc_pos = torch.zeros(...原创 2019-08-30 16:14:52 · 753 阅读 · 0 评论 -
部分tensorflow内置函数与pytorch内置函数的对应 --- 持续更新
TensorFlow - tf.reshape 函数 & Pytorch - torch.reshape 函数TensorFlowtf.reshape( tensor, shape:[int, …], name=None )Pytorchtorch.reshape(self: Tensor, shape: Tuple[int, …])TensorFlow - tf...原创 2019-09-02 17:44:52 · 14603 阅读 · 3 评论 -
torch输出元素值相等的多维张量
需转一次np数组,tensor不能与标量相乘。import numpy as npimport torcha = torch.ones_like((6,20,1))print(a.size)a = a.cpu().numpy()b = 0.3 * ab = torch.from_numpy(b)print(a)原创 2019-09-12 17:22:13 · 308 阅读 · 0 评论 -
tensorflow张量维度输出一个整数
import tensorflow as tfa = tf.constant([2,3,4])print(a.shape.as_list()[0])原创 2019-10-05 15:47:39 · 816 阅读 · 0 评论 -
tf.gather_nd 在 torch 中的实现
def th_gather_nd(x, coords): x = x.contiguous() inds = coords.mv(torch.LongTensor(x.stride())) x_gather = torch.index_select(x.contiguous().view(-1), 0, inds) return x_gather原创 2019-10-06 12:38:34 · 3081 阅读 · 1 评论