Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: forward() missing 1 required positional argument: 'x' #77

Open
joshclancy opened this issue Jun 20, 2020 · 1 comment
Open

Comments

@joshclancy
Copy link

Just started using hidden layer, looks great but haven't gotten it to work yet. I am not sure what I am doing wrong here.

import hiddenlayer as hl
graph = hl.build_graph(discriminator, torch.zeros([1, 1, 128, 128])) #My input is binary
graph = graph.build_dot()
graph.render(path, view=True, format='png')
837         from torchviz import make_dot
 838         import hiddenlayer as hl

---> 839 graph = hl.build_graph(discriminator, torch.zeros([1, 1, 128, 128]))
840 graph = graph.build_dot()
841 graph.render('C:\Users\joshu\Documents\2019_Flabels\2020_HC_VACS2', view=True, format='png')

~\Anaconda3\envs\flabels\lib\site-packages\hiddenlayer\graph.py in build_graph(model, args, input_names, transforms, framework_transforms)
141 from .pytorch_builder import import_graph, FRAMEWORK_TRANSFORMS
142 assert args is not None, "Argument args must be provided for Pytorch models."
--> 143 import_graph(g, model, args)
144 elif framework == "tensorflow":
145 from .tf_builder import import_graph, FRAMEWORK_TRANSFORMS

~\Anaconda3\envs\flabels\lib\site-packages\hiddenlayer\pytorch_builder.py in import_graph(hl_graph, model, args, input_names, verbose)
68
69 # Run the Pytorch graph to get a trace and generate a graph from it
---> 70 trace, out = torch.jit._get_trace_graph(model, args)
71 torch_graph = torch.onnx._optimize_trace(trace, torch.onnx.OperatorExportTypes.ONNX)
72

~\Anaconda3\envs\flabels\lib\site-packages\torch\jit_init_.py in _get_trace_graph(f, args, kwargs, _force_outplace, return_inputs, _return_inputs_states)
275 if not isinstance(args, tuple):
276 args = (args,)
--> 277 outs = ONNXTracedModule(f, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
278 return outs
279

~\Anaconda3\envs\flabels\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
530 result = self._slow_forward(*input, **kwargs)
531 else:
--> 532 result = self.forward(*input, **kwargs)
533 for hook in self._forward_hooks.values():
534 hook_result = hook(self, input, result)

~\Anaconda3\envs\flabels\lib\site-packages\torch\jit_init_.py in forward(self, *args)
358 in_vars + module_state,
359 _create_interpreter_name_lookup_fn(),
--> 360 self._force_outplace,
361 )
362

~\Anaconda3\envs\flabels\lib\site-packages\torch\jit_init_.py in wrapper(*args)
345 if self._return_inputs_states:
346 inputs_states.append(_unflatten(args[:len(in_vars)], in_desc))
--> 347 outs.append(self.inner(*trace_inputs))
348 if self._return_inputs_states:
349 inputs_states[0] = (inputs_states[0], trace_inputs)

~\Anaconda3\envs\flabels\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
528 input = result
529 if torch._C._get_tracing_state():
--> 530 result = self._slow_forward(*input, **kwargs)
531 else:
532 result = self.forward(*input, **kwargs)

~\Anaconda3\envs\flabels\lib\site-packages\torch\nn\modules\module.py in _slow_forward(self, *input, **kwargs)
514 recording_scopes = False
515 try:
--> 516 result = self.forward(*input, **kwargs)
517 finally:
518 if recording_scopes:

TypeError: forward() missing 1 required positional argument: 'x'

@samruddhishastri
Copy link

Hi, I am facing the same issue. Were you able to resolve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants