RuntimeError: expected stride to be a single integer value or a list of 1 values to match the convolution dimensions, but got stride=[1, 1] #126630
Unanswered
kkuingg
asked this question in
Programming Help
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
`def _kernelMult(kernel, maskFFT, kernelNum):
knx, kny = kernel.shape[-2:] # 커널의 가로 및 세로 크기
cx, cy = maskFFT.shape[-2] // 2, maskFFT.shape[-1] // 2
sx, sy = cx - knx // 2, cy - kny // 2
`cut_maskFFT shape: torch.Size([1, 1, 35, 35])
Input shape: torch.Size([1, 1, 35, 35])
Kernel shape: torch.Size([1, 35, 35])
Stride: (1, 1), Padding: (knx//2, kny//2)
RuntimeError Traceback (most recent call last)
in <cell line: 314>()
313
314 if name == "main":
--> 315 main()
10 frames
in main()
288 'DoseNom': 1.0
289 }
--> 290 optimized_bin = optimize_pattern(original_bin, defect_bin, config_lv)
291 display_results(original_bin.numpy(), defect_bin.numpy(), optimized_bin)
292
in optimize_pattern(original_bin, defect_bin, config_lv)
244 litho_sim_config = LithoSim(config_lv)
245 optimizer = MaskOptimizer(config_lv, litho_sim_config)
--> 246 optimized_mask = optimizer.optimize(original_tensor, defect_tensor)
247 return (optimized_mask * 255).astype(np.uint8)
248
in optimize(self, target, initial_mask)
221 for iteration in range(self.config_lv['Iterations']):
222 optimizer.zero_grad()
--> 223 nominal, max_exposure, min_exposure = self.lithosim(params)
224
225 l2_loss = F.mse_loss(nominal, target)
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in _wrapped_call_impl(self, *args, **kwargs)
1530 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1531 else:
-> 1532 return self._call_impl(*args, **kwargs)
1533
1534 def _call_impl(self, *args, **kwargs):
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in _call_impl(self, *args, **kwargs)
1539 or _global_backward_pre_hooks or _global_backward_hooks
1540 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1541 return forward_call(*args, **kwargs)
1542
1543 try:
in forward(self, mask)
191
192 def forward(self, mask):
--> 193 aerialNom = _LithoSim.apply(mask, self._config["DoseNom"],
194 self._kernels["focus"].kernels, self._kernels["focus"].scales, self._config["KernelNum"],
195 self._kernels["combo CT focus"].kernels, self._kernels["combo CT focus"].scales, 1,
/usr/local/lib/python3.10/dist-packages/torch/autograd/function.py in apply(cls, *args, **kwargs)
596 # See NOTE: [functorch vjp and autograd interaction]
597 args = _functorch.utils.unwrap_dead_wrappers(args)
--> 598 return super().apply(*args, **kwargs) # type: ignore[misc]
599
600 if not is_setup_ctx_defined:
in forward(ctx, mask, dose, kernel, scale, kernelNum, kernelGradCT, scaleGradCT, kernelNumGradCT, kernelGrad, scaleGrad, kernelNumGrad)
142 def forward(ctx, mask, dose, kernel, scale, kernelNum, kernelGradCT, scaleGradCT, kernelNumGradCT, kernelGrad, scaleGrad, kernelNumGrad):
143 ctx.saved = (mask, dose, kernel, scale, kernelNum, kernelGradCT, scaleGradCT, kernelNumGradCT, kernelGrad, scaleGrad, kernelNumGrad)
--> 144 return _convMask(mask, dose, kernel, scale, kernelNum)
145 @staticmethod
146 def backward(ctx, grad):
in _convMask(mask, dose, kernel, scale, kernelNum)
135 def _convMask(mask, dose, kernel, scale, kernelNum):
136 cmask = _maskFloat(mask, dose)
--> 137 image = _computeImage(cmask, kernel, scale, kernelNum)
138 return image
139
in _computeImage(cmask, kernel, scale, kernelNum)
116 cmask = torch.unsqueeze(cmask, 0)
117 cmask_fft = torch.fft.fft2(cmask, norm="forward")
--> 118 tmp = _kernelMult(kernel, cmask_fft, kernelNum)
119 tmp = torch.fft.ifft2(tmp, norm="forward")
120 if len(tmp.shape) == 3:
in _kernelMult(kernel, maskFFT, kernelNum)
101 print(f"Stride: (1, 1), Padding: (knx//2, kny//2)")
102
--> 103 output[:, i, :, :] = torch.nn.functional.conv2d(
104 cut_maskFFT, kernel[i:i+1], stride=(1, 1), padding=(knx//2, kny//2))
105 print("Output shape after conv:", output[:, i, :, :].shape)
RuntimeError: expected stride to be a single integer value or a list of 1 values to match the convolution dimensions, but got stride=[1, 1] `
I don't know why this error is happening. I think the stride is set up properly..
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions