我写了一个 torch_fenics 的子类。在这种情况下,输入是来自 DG 空间的向量。我在弱公式中使用此输入,然后计算解决方案。此外,我需要解决方案相对于给定输入的梯度。
I get the following error log on running the same
~/miniconda3/envs/py37/lib/python3.7/site-packages/torch/autograd/function.py in apply(self, *args) 75 76 def apply(self, *args): ---> 77 return self._forward_cls.backward(self, *args) 78 79
~/miniconda3/envs/py37/lib/python3.7/site-packages/torch_fenics/torch_fenics.py in backward(ctx, *grad_outputs) 88 # 检查哪些梯度需要计算 89 controls = list(map(fenics_adjoint.Control , ---> 90 (c for g, c in zip(ctx.needs_input_grad[1:], ctx.fenics_inputs) if g))) 91 92 # 针对每个输入计算和累积每个输出的梯度
~/miniconda3/envs/py37/lib/python3.7/site-packages/pyadjoint/control.py init (self, control) 38 def init (self, control): 39 self.control = control ---> 40 self.block_variable = control.block_variable 41 42 def data(self):
AttributeError:“函数”对象没有属性“block_variable”