Giter VIP home page Giter VIP logo

Comments (4)

drasmuss avatar drasmuss commented on July 20, 2024 1

It's not an identity connection (pre size != post size), so you can't use a scalar, you have to specify a full matrix. There's a separate issue of whether we want to allow Choice([0]) on identity connections, but that's an issue for nengo core (either one would work fine with freeze_params in NengoDL).

from nengo-dl.

arvoelke avatar arvoelke commented on July 20, 2024

Note: I also get a similar error when saving the params from transform = nengo.dists.Choice([0]) and then trying to load them into a model with transform = np.zeros((n_neurons, 1)):

----> 5     sim.keras_model.load_weights(fname)
      6     sim.freeze_params(net)

~/anaconda3/envs/nengo-dl/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py in load_weights(self, filepath, by_name)
    179         raise ValueError('Load weights is not yet supported with TPUStrategy '
    180                          'with steps_per_run greater than 1.')
--> 181     return super(Model, self).load_weights(filepath, by_name)
    182 
    183   @trackable.no_automatic_dependency_tracking

~/anaconda3/envs/nengo-dl/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py in load_weights(self, filepath, by_name)
   1175         saving.load_weights_from_hdf5_group_by_name(f, self.layers)
   1176       else:
-> 1177         saving.load_weights_from_hdf5_group(f, self.layers)
   1178 
   1179   def _updated_config(self):

~/anaconda3/envs/nengo-dl/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py in load_weights_from_hdf5_group(f, layers)
    697                        str(len(weight_values)) + ' elements.')
    698     weight_value_tuples += zip(symbolic_weights, weight_values)
--> 699   K.batch_set_value(weight_value_tuples)
    700 
    701 

~/anaconda3/envs/nengo-dl/lib/python3.7/site-packages/tensorflow_core/python/keras/backend.py in batch_set_value(tuples)
   3356             assign_placeholder = array_ops.placeholder(tf_dtype,
   3357                                                        shape=value.shape)
-> 3358             assign_op = x.assign(assign_placeholder)
   3359             x._assign_placeholder = assign_placeholder
   3360             x._assign_op = assign_op

~/anaconda3/envs/nengo-dl/lib/python3.7/site-packages/tensorflow_core/python/ops/resource_variable_ops.py in assign(self, value, use_locking, name, read_value)
    812     with _handle_graph(self.handle):
    813       value_tensor = ops.convert_to_tensor(value, dtype=self.dtype)
--> 814       self._shape.assert_is_compatible_with(value_tensor.shape)
    815       assign_op = gen_resource_variable_ops.assign_variable_op(
    816           self.handle, value_tensor, name=name)

~/anaconda3/envs/nengo-dl/lib/python3.7/site-packages/tensorflow_core/python/framework/tensor_shape.py in assert_is_compatible_with(self, other)
   1113     """
   1114     if not self.is_compatible_with(other):
-> 1115       raise ValueError("Shapes %s and %s are incompatible" % (self, other))
   1116 
   1117   def most_specific_compatible_shape(self, other):

ValueError: Shapes (128, 1) and (128,) are incompatible

This hints to me that the parameters in the underlying model should have been (128, 1), in the case of transform = nengo.dists.Choice([0]), but were squeezed down to (128,).

from nengo-dl.

drasmuss avatar drasmuss commented on July 20, 2024

Took me a while to spot this, but transform = nengo.dists.Choice([0]) isn't actually a valid transform. It should be nengo.dists.Choice([[0]]). If you try your code snippet in the regular Nengo simulator you'll see that you get an error there as well. It kind of works in NengoDL (other than the freeze_params thing) due to broadcasting, but that isn't intended/supported behaviour. I've submitted a fix in Nengo core to address the underlying issue (there should have been a proper validation message indicating that the Choice dist had the wrong dimensionality), see nengo/nengo#1630.

from nengo-dl.

hunse avatar hunse commented on July 20, 2024

Shouldn't Choice([0]) be a valid transform, because we allow setting the transform as a scalar? i.e., Connection(a, b, transform=0) is permitted, and Connection(a, b, transform=Choice([0])) should be equivalent to that (since sampling that distribution will always return 0).

from nengo-dl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.