如何更改 Pytorch 预训练网络的激活层?这是我的代码:
print("All modules")
for child in net.children():
if isinstance(child,nn.ReLU) or isinstance(child,nn.SELU):
print(child)
print('Before changing activation')
for child in net.children():
if isinstance(child,nn.ReLU) or isinstance(child,nn.SELU):
print(child)
child=nn.SELU()
print(child)
print('after changing activation')
for child in net.children():
if isinstance(child,nn.ReLU) or isinstance(child,nn.SELU):
print(child)
Run Code Online (Sandbox Code Playgroud)
这是我的输出:
All modules
ReLU(inplace=True)
Before changing activation
ReLU(inplace=True)
SELU()
after changing activation
ReLU(inplace=True)
Run Code Online (Sandbox Code Playgroud) python neural-network deep-learning activation-function pytorch
我试图将转移学习与受过训练的[3D]CNN结合使用,在那里我对模型及其权重进行了训练。
但是问题是它的输入大小为,(64,64,7,3)而我的输入大小为(256,256,256,1)。我该如何解决这个问题?
我想scipy.signal.fftconvolve在 Tensorflow/Keras 中使用,有什么办法吗?
现在我正在使用以下代码:
window = np.tile(window, (1, 1, 1, 3))
tf.nn.conv2d(img1, window, strides=[1,1,1,1], padding='VALID')
Run Code Online (Sandbox Code Playgroud)
这些行是否等效于:
signal.fftconvolve(img1, window, mode='valid')
Run Code Online (Sandbox Code Playgroud)