반응형
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd
import Variable
import numpy as np
input = torch.Tensor(np.array([[[ [1,1,1,0,0], [0,1,1,1,0], [0,0,1,1,1], [0,0,1,1,0], [0,1,1,0,0] ]]]))
filter = torch.Tensor(np.array([[[ [1,0,1], [0,1,0], [1,0,1] ]]]))
input = Variable(input, requires\_grad=True)
filter = Variable(filter)
out = F.conv2d(input, filter)
print(out)