03 2021 档案
摘要:1.torch.eq out = torch.eq(input, other) 功能: 比较两个张量的元素是否相同 参数: input:输入的张量 other: 用于比较的张量 out: 输出元素为True或者是Flase的张量 例子: 例子1: >>> torch.eq(torch.tensor(
阅读全文
摘要:## 在torch中softmax的使用在torch中softmax的使用 在哪一维度上进行softmax操作,哪一维度的值之和为1 class Fc(nn.Module): def __init__(self, in_channel, out_channel): super(Fc, self)._
阅读全文
摘要:python中reduce 与map的用法 reduce的工作过程是: 在迭代sequence(tuple ,list ,dictionary, string等可迭代物)的过程中, 首先把前两个元素传给 函数参数,函数加工后, 然后把得到的结果和第三个元素作为两个参数传给函数参数, 函数加工后得到的
阅读全文
摘要:Pytorch :list, numpy.array, torch.Tensor 格式相互转化 同时解决 ValueError:only one element tensors can be converted to Python scalars 问题 - torch.Tensor 转 numpy
阅读全文
摘要:下载extundelete sudo apt-get install extundelete 获取大概删除时间点之后文件。(假设是11点26删除的文件,恢复11点25以后误删的文件)。 date -d "2021-03-15 11:25:00" +%s 如果不确定几点几分直接 date -d "20
阅读全文
摘要:使用方法: from abc import abstractmethod 1.含abstractmethod的方法由子类的相同函数重写 举例: from abc import abstractmethod class BaseModel(object): def __init__(self): se
阅读全文
摘要:pytorch输入数据PipeLine一般遵循一个“三步走”的策略,一般pytorch 的数据加载到模型的操作顺序是这样的: ① 创建一个 Dataset 对象。必须实现__len__()、getitem()这两个方法,这里面会用到transform对数据集进行扩充。 ② 创建一个 DataLoad
阅读全文
摘要:有一个(类)损失函数名字中带了with_logits. 而这里的logits指的是,该损失函数已经内部自带了计算logit的操作, 无需在传入给这个loss函数之前手动使用sigmoid/softmax将之前网络的输入映射到[0,1]之间 来自:https://blog.csdn.net/u0106
阅读全文
摘要:import torch a = [torch.arange(12).reshape(3, 4)] print(a) b = torch.cat(a, dim=0) print(b) 使用torch.cat去除[]
阅读全文
摘要:class Foo(): def __init__(self, x): print("this is class of Foo.") print("Foo类属性初始化") self.f = "foo" print(x) class Children(Foo): def __init__(self):
阅读全文
摘要:np.mean(data, axis=0) 假如data为2维数组,形如(3, 4),此时axis= 0的操作其实等价为 在轴0处求平均,然后执行np.squeeze操作 图形解释: data = np.arange(12).reshape(3, 4) mean = np.mean(data, ax
阅读全文
摘要:将一个文件夹变成了一个包 可以通过文件夹名.函数调用__init__.py里的函数 例如: -文件夹(net) -py文件(__init__.py) -py文件(main.py) 文件存储格式如上所示 __init__.py def get(): return 0 main.py from net
阅读全文
摘要:nn.Sequential用法 将多个模块进行封装 layer = nn.Sequential(nn.Conv2d(in_channels=128, out_channels=64,kernel_size) nn.Sequential内部实现了forward功能,可以直接调用 例如: x = tor
阅读全文
摘要:普通字典(dict) 遍历字典,返回数据,和定义字典时的字段顺序,不一致。 按顺序插入,遍历时,不顺序返回。 有序字典(collections.OrderedDict) 遍历字典,返回数据,和定义字典时数据顺序,一致。 按顺序插入,遍历时,按顺序返回。 注:python3.6以后版本无区别!!!!!
阅读全文