import torch
from torch import nn
from torchvision.utils import make_grid
from torch.nn import init
import matplotlib.pyplot as plt
class Model(nn.Module):
def __init__(self, num_layers=18):
super(Model, self).__init__()
convs = [
nn.Conv2d(1, 1, 3, padding=1, bias=False)
for i in range(num_layers)
]
for conv in convs:
init.constant_(conv.weight, 1)
self.layers = nn.Sequential(*convs)
def forward(self, x):
return self.layers(x)
model = Model()
x = torch.ones(1, 1, 256, 256)
x.requires_grad = True
y = model(x)
mask = torch.zeros_like(y, dtype=torch.float)
mask[0, 0, 128, 128] = 1
y = y * mask
torch.autograd.backward(y, x)
image = torch.cat([x, y, x.grad], dim=0)
image = make_grid(image)
# image = image / image.max()
image = image.permute(1, 2, 0)
plt.imshow(image)
plt.show()
Effective Receptive Field (ERFs)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- lucene在doc.add(new Field("content",curArt.getContent(),Fi...
- Field types(字段类型) AutoField class AutoField(**options) 一个...
- multi_match | 三种场景 最佳字段 | best_field 当字段之间相互竞争,又相互关联,例如 t...
- Field options (字段选项。以下参数可用于所有字段类型。所有都是可选的。) Field.null 如果...
- 那么怎么解决呢 1、在form组件显示出后,再用this.form.setFieldsValue 2、在this....