AttributeError: 'Function' object has no attribute 'block_variable'

492 Views Asked by At

I have written a subclass of torch_fenics. In this, the input is a vector from DG space. I use this input in the weak formulation and then calculate the solution. Further, I need the gradient of the solution with respect to the given input.


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 # Check which gradients need to be computed 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 # Compute and accumulate gradient for each output with respect to each input

~/miniconda3/envs/py37/lib/python3.7/site-packages/pyadjoint/control.py in 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: 'Function' object has no attribute 'block_variable'

1

There are 1 best solutions below

0
On

Don't import dolfin in your code. It will resolve the issue.