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

ZeroDivsion error? #151

Open
ziweiyang opened this issue Apr 5, 2023 · 2 comments
Open

ZeroDivsion error? #151

ziweiyang opened this issue Apr 5, 2023 · 2 comments

Comments

@ziweiyang
Copy link

Hi developer,

Thanks for sharing this work. I am trying to reproduce the MeshGraphNet developed by Deepminds in 2021, by using the module.EncodeProcessDecode and module.InteractionNetwroks.

I am using demo.tf2 as prototype and replace self._core with module.InteractionNetwork. I am only using test.tfrecord in original cylinder_flow case for easy testing the model on colab. (There is no global features, and num_nodes/num_edges equal to num_vertices/num_edges in that moment of mesh-space). I define each individual timestep as a GraphTuple. Everything works fine until I started the actual training loop, then I got this error message:

StagingError: in user code:

File "<ipython-input-32-abdb2890eda7>", line 19, in update_step  *
    pred = model(inputs_tr, stats_list[0], stats_list[1], stats_list[2], stats_list[3], params.message_passing_steps)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "<ipython-input-15-c64a739fd414>", line 98, in __call__  *
    latent = self._encoder(inputs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "<ipython-input-15-c64a739fd414>", line 31, in __call__  *
    return self._network(inputs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/graph_nets/_base.py", line 78, in __call__  *
    return self._build(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/graph_nets/modules.py", line 368, in _build  *
    globals=self._global_model(graph.globals))
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/graph_nets/_base.py", line 78, in __call__  *
    return self._build(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/graph_nets/_base.py", line 112, in _build  *
    return self._model(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/sequential.py", line 68, in __call__  *
    outputs = mod(outputs, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/nets/mlp.py", line 97, in __call__  *
    inputs = layer(inputs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/linear.py", line 83, in __call__  *
    self._initialize(inputs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/once.py", line 89, in wrapper  *
    _check_no_output(wrapped(*args, **kwargs))
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/utils.py", line 85, in _decorate_unbound_method  *
    return decorator_fn(bound_method, self, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/base.py", line 262, in wrap_with_name_scope  *
    return method(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/sonnet/src/linear.py", line 71, in _initialize  *
    stddev = 1 / math.sqrt(self.input_size)

ZeroDivisionError: float division by zero

I am not sure where I should look at to solve this. Any ideas?

Best,
ZY

@alvarosg
Copy link
Collaborator

This sounds like one of the vectors of features you are building (e.g. node features or edge features), have zero dimensionality. So this is trying to instantiate a weight of size [0, N], and it is failing when running the initialization for that weight.

@ziweiyang
Copy link
Author

Hi @alvarosg , thanks for your comment. I figured it out like what you mentioned here. Thanks for sharing this library, which saves my lots of work.

Best,
ZY

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