多GPU使用,直接改环境变量设置:
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3'
想知道num_workers怎么设:
from multiprocessing import cpu_count
threads = cpu_count()
关于conv2d参数的设置:
当输入 H1*W1,步长stride S,零填充padding P,卷积核尺寸K*K
输出尺寸
W2 = (W1 - K + 2P + S) / S,
H2 = (H1 - K + 2P + S) / S。
当W2,H2不为整数时,超参数设置非法,pytorch报错。
如何保证输出高宽尺寸一致?S=1时,设置 P = (F -1)/2即可。难怪卷积核尺寸一般都是奇数。
pytorch的gather方法的使用:
import torch
import numpy as np
a = torch.Tensor(np.random.random([3,5]))
b = [1,2,3]
a
Out[2]:
0.0348 0.3424 0.1292 0.2874 0.3212
0.1665 0.1182 0.3331 0.1454 0.1170
0.2302 0.1205 0.5400 0.2291 0.4758
[torch.FloatTensor of size 3x5]
a.gather(1, torch.LongTensor([1,2,3]).unsqueeze(-1)) #第一个参数是进行gather操作的维度
Out[3]:
0.3424
0.3331
0.2291
[torch.FloatTensor of size 3x1]
tensorboard报错 Fatal error in launcher: Unable to create process using '"'
解决方法:python -m tensorflow.tensorboard --logdir=runs