I am trying to construct a complex geometry by using the difference method.
It is simply a large rectangle with removing a smaller rectangle.
The union implementation works well but the difference results in an error as below.
Could you tell me how to fix the error? Thanks!
RuntimeError Traceback (most recent call last)
C:\Users\LIC32C~1.JIA\AppData\Local\Temp/ipykernel_23124/1412010660.py in <module>
56
57 model.compile("adam", lr=0.001)
---> 58 model.train(epochs=20000)
59 model.compile("L-BFGS")
60 losshistory, train_state = model.train()
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\deepxde\utils\internal.py in wrapper(*args, **kwargs)
20 def wrapper(*args, **kwargs):
21 ts = timeit.default_timer()
---> 22 result = f(*args, **kwargs)
23 te = timeit.default_timer()
24 print("%r took %f s\n" % (f.__name__, te - ts))
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\deepxde\model.py in train(self, epochs, batch_size, display_every, disregard_previous_best, callbacks, model_restore_path, model_save_path)
416 self.train_state.set_data_train(*self.data.train_next_batch(self.batch_size))
417 self.train_state.set_data_test(*self.data.test())
--> 418 self._test()
419 self.callbacks.on_train_begin()
420 if optimizers.is_external_optimizer(self.opt_name):
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\deepxde\model.py in _test(self)
548 self.train_state.y_pred_train,
549 self.train_state.loss_train,
--> 550 ) = self._outputs_losses(
551 True,
552 self.train_state.X_train,
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\deepxde\model.py in _outputs_losses(self, training, inputs, targets, auxiliary_vars)
345 # TODO: auxiliary_vars
346 self.net.requires_grad_(requires_grad=False)
--> 347 outs = self.outputs_losses(training, inputs, targets)
348 self.net.requires_grad_()
349 elif backend_name == "jax":
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\deepxde\model.py in outputs_losses(training, inputs, targets)
227 self.net.inputs = torch.as_tensor(inputs)
228 self.net.inputs.requires_grad_()
--> 229 outputs_ = self.net(self.net.inputs)
230 # Data losses
231 if targets is not None:
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1102 return forward_call(*input, **kwargs)
1103 # Do not call functions when jit is used
1104 full_backward_hooks, non_full_backward_hooks = [], []
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\deepxde\nn\pytorch\fnn.py in forward(self, inputs)
31 x = self._input_transform(x)
32 for linear in self.linears[:-1]:
---> 33 x = self.activation(linear(x))
34 x = self.linears[-1](x)
35 if self._output_transform is not None:
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1102 return forward_call(*input, **kwargs)
1103 # Do not call functions when jit is used
1104 full_backward_hooks, non_full_backward_hooks = [], []
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\torch\nn\modules\linear.py in forward(self, input)
101
102 def forward(self, input: Tensor) -> Tensor:
--> 103 return F.linear(input, self.weight, self.bias)
104
105 def extra_repr(self) -> str:
~\Anaconda3\envs\pytorch-gpu\lib\site-packages\torch\nn\functional.py in linear(input, weight, bias)
1846 if has_torch_function_variadic(input, weight, bias):
1847 return handle_torch_function(linear, (input, weight, bias), input, weight, bias=bias)
-> 1848 return torch._C._nn.linear(input, weight, bias)
1849
1850
RuntimeError: expected scalar type Float but found Double
Dear Prof. Lu
I am trying to construct a complex geometry by using the difference method. It is simply a large rectangle with removing a smaller rectangle. The union implementation works well but the difference results in an error as below. Could you tell me how to fix the error? Thanks!
The script I am using is as follows: