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

Nodes without feature #22

Closed
FarshidShekari opened this issue Nov 18, 2018 · 6 comments
Closed

Nodes without feature #22

FarshidShekari opened this issue Nov 18, 2018 · 6 comments

Comments

@FarshidShekari
Copy link

My nodes haven't feature in my problem and I used None for that purpose but I get below error when running my code:
AttributeError: 'NoneType' object has no attribute 'get_shape'

when I added popery to feature I can run it.

tnx

@vbapst
Copy link

vbapst commented Nov 18, 2018

Hi Farshid,

can you provide a more complete stack trace ? Thanks.

@FarshidShekari
Copy link
Author

Hi @vbapst
This is my stack trace:
Traceback (most recent call last):

  File "C:/Users/Farshid/PycharmProjects/clique/Main2.py", line 112, in <module>
    output_ops_tr = model(input_ph, num_processing_steps_tr)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 389, in __call__
    outputs, subgraph_name_scope = self._template(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 360, in __call__
    return self._call_func(args, kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 311, in _call_func
    result = self._func(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 246, in _build_wrapper
    output = self._build(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 122, in _build
    latent = self._encoder(input_op)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 389, in __call__
    outputs, subgraph_name_scope = self._template(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 360, in __call__
    return self._call_func(args, kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 311, in _call_func
    result = self._func(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 246, in _build_wrapper
    output = self._build(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 56, in _build
    return self._network(inputs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 389, in __call__
    outputs, subgraph_name_scope = self._template(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 360, in __call__
    return self._call_func(args, kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 311, in _call_func
    result = self._func(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 246, in _build_wrapper
    output = self._build(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\modules.py", line 366, in _build
    edges=self._edge_model(graph.edges),
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 389, in __call__
    outputs, subgraph_name_scope = self._template(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 360, in __call__
    return self._call_func(args, kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 311, in _call_func
    result = self._func(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 246, in _build_wrapper
    output = self._build(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 715, in _build
    return self._build_function(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\modules.py", line 342, in <lambda>
    lambda x: edge_model_fn()(x), name="edge_model")  # pylint: disable=unnecessary-lambda
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 389, in __call__
    outputs, subgraph_name_scope = self._template(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 360, in __call__
    return self._call_func(args, kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 311, in _call_func
    result = self._func(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 246, in _build_wrapper
    output = self._build(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\sequential.py", line 103, in _build
    net = layer(*net)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 389, in __call__
    outputs, subgraph_name_scope = self._template(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 360, in __call__
    return self._call_func(args, kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 311, in _call_func
    result = self._func(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 246, in _build_wrapper
    output = self._build(*args, **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\nets\mlp.py", line 143, in _build
    self._input_shape = tuple(inputs.get_shape().as_list())
AttributeError: 'NoneType' object has no attribute 'get_shape'

originally defined at:
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 39, in make_mlp_model
    snt.nets.MLP([LATENT_SIZE] * NUM_LAYERS, activate_final=True),
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\nets\mlp.py", line 81, in __init__
    super(MLP, self).__init__(custom_getter=custom_getter, name=name)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 215, in __init__
    custom_getter_=self._custom_getter)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 154, in make_template
    **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 224, in make_template_internal
    create_graph_function=create_graph_function_)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 281, in __init__
    self._stacktrace = traceback.format_stack()[:-2]


originally defined at:
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 40, in make_mlp_model
    snt.LayerNorm()
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\sequential.py", line 65, in __init__
    super(Sequential, self).__init__(name=name)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 215, in __init__
    custom_getter_=self._custom_getter)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 154, in make_template
    **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 224, in make_template_internal
    create_graph_function=create_graph_function_)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 281, in __init__
    self._stacktrace = traceback.format_stack()[:-2]


originally defined at:
  File "C:/Users/Farshid/PycharmProjects/clique/Main2.py", line 110, in <module>
    model = models.EncodeProcessDecode(edge_output_size=2, node_output_size=2)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 101, in __init__
    self._encoder = MLPGraphIndependent()
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 53, in __init__
    global_model_fn=make_mlp_model)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\modules.py", line 342, in __init__
    lambda x: edge_model_fn()(x), name="edge_model")  # pylint: disable=unnecessary-lambda
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 710, in __init__
    super(Module, self).__init__(custom_getter=custom_getter, name=name)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 215, in __init__
    custom_getter_=self._custom_getter)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 154, in make_template
    **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 224, in make_template_internal
    create_graph_function=create_graph_function_)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 281, in __init__
    self._stacktrace = traceback.format_stack()[:-2]


originally defined at:
  File "C:/Users/Farshid/PycharmProjects/clique/Main2.py", line 110, in <module>
    model = models.EncodeProcessDecode(edge_output_size=2, node_output_size=2)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 101, in __init__
    self._encoder = MLPGraphIndependent()
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 53, in __init__
    global_model_fn=make_mlp_model)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\modules.py", line 332, in __init__
    super(GraphIndependent, self).__init__(name=name)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 215, in __init__
    custom_getter_=self._custom_getter)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 154, in make_template
    **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 224, in make_template_internal
    create_graph_function=create_graph_function_)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 281, in __init__
    self._stacktrace = traceback.format_stack()[:-2]


originally defined at:
  File "C:/Users/Farshid/PycharmProjects/clique/Main2.py", line 110, in <module>
    model = models.EncodeProcessDecode(edge_output_size=2, node_output_size=2)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 101, in __init__
    self._encoder = MLPGraphIndependent()
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 48, in __init__
    super(MLPGraphIndependent, self).__init__(name=name)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 215, in __init__
    custom_getter_=self._custom_getter)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 154, in make_template
    **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 224, in make_template_internal
    create_graph_function=create_graph_function_)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 281, in __init__
    self._stacktrace = traceback.format_stack()[:-2]


originally defined at:
  File "C:/Users/Farshid/PycharmProjects/clique/Main2.py", line 110, in <module>
    model = models.EncodeProcessDecode(edge_output_size=2, node_output_size=2)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\demos\models.py", line 100, in __init__
    super(EncodeProcessDecode, self).__init__(name=name)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\sonnet\python\modules\base.py", line 215, in __init__
    custom_getter_=self._custom_getter)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 154, in make_template
    **kwargs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 224, in make_template_internal
    create_graph_function=create_graph_function_)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\template.py", line 281, in __init__
    self._stacktrace = traceback.format_stack()[:-2]

@vbapst
Copy link

vbapst commented Nov 19, 2018

Hi Farshid,

you cannot use a GraphIndependent module if your input graph has not node states. Either provide dummy features, or do the initial encoding of your graph yourself.

@FarshidShekari
Copy link
Author

thank you.

@alvarosg
Copy link
Collaborator

Alternatively it should be possible to just specify node_model_fn=None, and then the None nodes will be passed directly to the output the GraphIndependent as None.

You will then find a similar problem when you feed the output of GraphIndependent to as input to the next GraphNetwork, and you would have to set to False, the corresponding use_*_nodes parameters via edge_block_opt, node_block_opt, global_block_opt.

In practice, it is much more convenient to just put dummy zero node features in your input GraphsTuple. You can do is as easily as:
graph_with_dummy_nodes = utils_tf.set_zero_node_features(input_graph, node_size=1)

@FarshidShekari
Copy link
Author

FarshidShekari commented Nov 19, 2018

@vbapst I used dummy features but I get below error. In my problem, the input graph has no feature (edges and nodes) but the output graph nodes and edges have one feature:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1664, in <module>
    main()
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1658, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1068, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/Farshid/PycharmProjects/clique/Main2.py", line 171, in <module>
    theta, input_ph, target_ph)
  File "C:\Users\Farshid\PycharmProjects\clique\Helper2.py", line 302, in create_feed_dict
    input_graphs = utils_np.networkxs_to_graphs_tuple(inputs)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\utils_np.py", line 343, in networkxs_to_graphs_tuple
    return data_dicts_to_graphs_tuple(data_dicts)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\utils_np.py", line 381, in data_dicts_to_graphs_tuple
    _check_valid_sets_of_keys(data_dicts)
  File "C:\Users\Farshid\AppData\Local\Programs\Python\Python35\lib\site-packages\graph_nets\utils_np.py", line 85, in _check_valid_sets_of_keys
    "({} vs {})".format(prev_keys, current_keys))
ValueError: Different set of keys found when iterating over data dictionaries ({'edges', 'nodes', 'n_edge', 'receivers', 'globals', 'n_node', 'senders'} vs {'nodes', 'n_edge', 'receivers', 'globals', 'n_node', 'senders'})

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

3 participants