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

Tensorflow error when saving params with probed weights #56

Closed
hunse opened this issue Sep 7, 2018 · 1 comment
Closed

Tensorflow error when saving params with probed weights #56

hunse opened this issue Sep 7, 2018 · 1 comment

Comments

@hunse
Copy link
Collaborator

hunse commented Sep 7, 2018

When trying to use get_nengo_params on a connection with probed weights, I get the error below. This only seems to happen after 6ddf68e.

Traceback (most recent call last):
  File "test_save_nengo_params.py", line 33, in <module>
    params = sim.get_nengo_params(conn, as_dict=False)
  File "/data/eric/workspace/nengo_dl/nengo_dl/simulator.py", line 892, in get_nengo_params
    data = self.data.get_params(*fetches)
  File "/data/eric/workspace/nengo_dl/nengo_dl/simulator.py", line 1488, in get_params
    fetches[placeholder] = self.sim.tensor_graph.get_tensor(sig)
  File "/data/eric/workspace/nengo_dl/nengo_dl/tensor_graph.py", line 29, in func_with_self
    return func(self, *args, **kwargs)
  File "/data/eric/workspace/nengo_dl/nengo_dl/tensor_graph.py", line 712, in get_tensor
    return tf.gather(base, tensor_sig.tf_indices)
  File "/home/eric/venv/full3/lib/python3.4/site-packages/tensorflow/python/ops/array_ops.py", line 2585, in gather
    params, indices, validate_indices=validate_indices, name=name)
  File "/home/eric/venv/full3/lib/python3.4/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1864, in gather
    validate_indices=validate_indices, name=name)
  File "/home/eric/venv/full3/lib/python3.4/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/eric/venv/full3/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 3160, in create_op
    op_def=op_def)
  File "/home/eric/venv/full3/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 1672, in __init__
    control_flow_util.CheckInputFromValidContext(self, input_tensor.op)
  File "/home/eric/venv/full3/lib/python3.4/site-packages/tensorflow/python/ops/control_flow_util.py", line 200, in CheckInputFromValidContext
    raise ValueError(error_msg + " See info log for more details.")
ValueError: Cannot use 'while/iteration_0/Const_3' as input to 'Gather' because 'while/iteration_0/Const_3' is in a while loop. See info log for more details.

Here's a MWE:

import numpy as np
import nengo
import nengo_dl
from nengo_dl import tensor_layer


DO_ERROR = True

n_inputs = 3
n_neurons = 2

neuron_type = nengo_dl.SoftLIFRate()

# --- make network
with nengo.Network() as net:
    nengo_dl.configure_settings(trainable=None)
    net.config[nengo.Connection].synapse = None
    net.config[nengo.Ensemble].trainable = False

    inp = nengo.Node(np.zeros(n_inputs), label='input_node')
    layer, layer_conn = tensor_layer(inp, neuron_type,
                                     transform=nengo_dl.dists.Glorot(),
                                     shape_in=n_neurons,
                                     return_conn=True)

    if DO_ERROR:
        nengo.Probe(layer_conn, 'weights')

with nengo_dl.Simulator(net, minibatch_size=1) as sim:
    for conn in net.connections:
        print(conn)
        params = sim.get_nengo_params(conn, as_dict=False)
@drasmuss
Copy link
Member

Should be fixed in #57, let me know if that works for you!

drasmuss added a commit that referenced this issue Sep 11, 2018
drasmuss added a commit that referenced this issue Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants