TensorBoard with multiple inputs

username: YoushaaMurhij
cooked: <p>I can’t view the model structure using add_graph().</p>
<p>I have this input to the model (a dictionary of tensors and other inputs):</p>
<pre><code class="lang-auto">        grid_size = self.voxel_generator.grid_size
        coords = np.pad(coords, ((0, 0), (1, 0)), mode='constant', constant_values=0)

        voxels = torch.tensor(voxels, dtype=torch.float32, device=self.device)
        coords = torch.tensor(coords, dtype=torch.int32, device=self.device)
        num_points = torch.tensor(num_points, dtype=torch.int32, device=self.device)
        num_voxels = torch.tensor(num_voxels, dtype=torch.int32, device=self.device)

        self.inputs = dict(
            voxels=voxels,
            num_points=num_points,
            num_voxels=num_voxels,
            coordinates=coords,
            shape=[grid_size]
        )
        torch.cuda.synchronize()

        with torch.no_grad():
            outputs = self.net(self.inputs, return_loss=False)[0]

        writer.add_graph(self.net, self.inputs)

</code></pre>
<p>I got this error :</p>
<pre><code class="lang-auto">
 writer.add_graph(self.net, self.inputs)
  File "/usr/local/lib/python3.8/dist-packages/torch/utils/tensorboard/writer.py", line 724, in add_graph
    self._get_file_writer().add_graph(graph(model, input_to_model, verbose))
  File "/usr/local/lib/python3.8/dist-packages/torch/utils/tensorboard/_pytorch_graph.py", line 292, in graph
    raise e
  File "/usr/local/lib/python3.8/dist-packages/torch/utils/tensorboard/_pytorch_graph.py", line 286, in graph
    trace = torch.jit.trace(model, args)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 733, in trace
    return trace_module(
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py", line 934, in trace_module
    module._c._create_method_from_trace(
RuntimeError: Tracer cannot infer type of ({'voxels': tensor([[[ 9.3375,  1.9286, -0.1664,  0.0000,  0.0000],
         [ 9.2331,  1.9070,  0.2744,  0.0000,  0.0000],
         [ 9.3912,  1.9055, -0.1673,  0.0000,  0.0000],
         ...,
         [ 9.3165,  1.8972, -1.9016,  0.0000,  0.0000],
         [ 9.2892,  1.8916, -0.0551,  0.0000,  0.0000],
         [ 9.2425,  1.8821,  0.3843,  0.0000,  0.0000]],

        [[ 6.8277,  1.0655, -1.9345,  0.0000,  0.0000],
         [ 6.8314,  1.0417, -1.9345,  0.0000,  0.0000],
         [ 6.8388,  1.0184, -1.9356,  0.0000,  0.0000],
         ...,
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000]],

        [[ 9.4154,  1.0012, -1.8937,  0.0000,  0.0000],
         [ 9.4149,  1.1760, -1.8976,  0.0000,  0.0000],
         [ 9.4229,  1.1436, -1.8984,  0.0000,  0.0000],
         ...,
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000]],

        ...,

        [[10.5405,  1.6167, -1.6590,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         ...,
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000]],

        [[13.8343,  1.4345,  0.5666,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         ...,
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000]],

        [[15.3778,  1.4861, -0.4496,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         ...,
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000]]], device='cuda:0'), 'num_points': tensor([20, 12,  7,  ...,  1,  1,  1], device='cuda:0', dtype=torch.int32), 'num_voxels': tensor([12408], device='cuda:0', dtype=torch.int32), 'coordinates': tensor([[  0,   0, 265, 302],
        [  0,   0, 261, 290],
        [  0,   0, 261, 303],
        ...,
        [  0,   0, 264, 308],
        [  0,   0, 263, 325],
        [  0,   0, 263, 332]], device='cuda:0', dtype=torch.int32), 'shape': [array([512, 512,   1])]},)
:Could not infer type of list element: Only tensors and (possibly nested) tuples of tensors, lists, or dictsare supported as inputs or outputs of traced functions, but instead got value of type ndarray.
</code></pre>