小行星

热爱平淡,向往未知


  • 首页

  • 分类

  • 归档

  • 关于

  • 阅读排行

  • 搜索

ubuntu网速监控

发表于 2018-09-Sun | 阅读次数:
1
2
iftop
iptraf

git tag使用

发表于 2018-09-Sat | 阅读次数:
1
2
3
4
5
git tag -a <版本号> -m "<备注信息>"

git tag -d <版本号>

git push origin --tags

cv numpy截取区域

发表于 2018-09-Fri | 阅读次数:

在cv和numpy中截取区域的操作是不一样的
xmin, xmax, ymin, ymax

cv.draw(xmin: xmax, ymin: ymax)

a[ymin:ymax, xmin:xmax]

pytorch freeze一些层

发表于 2018-09-Fri | 阅读次数:
1
2
3
4
5
6
7
8
ignored_params = list(map(id, model.fc.parameters()))
base_params = filter(lambda p: id(p) not in ignored_params,
model.parameters())

optimizer = torch.optim.SGD([
{'params': base_params},
{'params': model.fc.parameters(), 'lr': opt.lr}
], lr=opt.lr*0.1, momentum=0.9)

numpy broadcasting原则

发表于 2018-09-Thu | 阅读次数:

右对齐

1
2
3
A      (4d array):  8 x 1 x 6 x 1
B (3d array): 7 x 1 x 5
Result (4d array): 8 x 7 x 6 x 5

pytorch tensor存储理解

发表于 2018-09-Thu | 阅读次数:

一层集装箱,每个集装箱里面装了物体, 如果一层的物体的stride是一样的,那么就合并成一个。

1
2
3
4
5
6
7
8
9
10
typedef struct THStorage
{
real *data;
ptrdiff_t size;
int refcount;
char flag;
THAllocator *allocator;
void *allocatorContext;
struct THStorage *view;
} THStorage;

1
2
3
4
5
6
7
8
9
10
11
12
13
typedef struct THTensor
{
int64_t *size; // 注意是指针
int64_t *stride; // 注意是指针
int nDimension;

// Note: storage->size may be greater than the recorded size
// of a tensor
THStorage *storage;
ptrdiff_t storageOffset;
int refcount;
char flag;
} THTensor;

python numpy 传参

发表于 2018-09-Wed | 分类于 长文 | 阅读次数:

a = b
只有当a[:], a[1]的时候b会发生变化;
如果只是a=b, 那么只是改变了引用。

1
2
3
4
5
6
7
a = np.zeros((2,2))
b = a[0]
b[0] = 1
print(a)

[[ 1. 0.]
[ 0. 0.]]

1
2
3
4
5
6
7
a = np.zeros((2,2))
b = a[0]
b = np.ones(10)
print(a)

[[ 0. 0.]
[ 0. 0.]]

函数传入参数也是如此

pytorch tensor整数除法

发表于 2018-09-Tue | 阅读次数:
1
2
3
4
a = torch.Tensor([1, 3])
b = torch.Tensor([1, 4])
torch.sum(a == b) * 1.0 / 3 # ==> 0
torch.sum(a == b).item() * 1.0 / 3

tensorflow-cuda版本

发表于 2018-09-Tue | 阅读次数:



pytorch torch.max返回2个值

发表于 2018-09-Tue | 阅读次数:

今早调用torch.max的时候出现了tuple,
后来发现是因为它返回2个值

1…151617…59
fangyh

fangyh

最爱的是那苍穹之外的浩渺宇宙

588 日志
4 分类
66 标签
© 2020 fangyh
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.3
|本站总访问量次