CNN spiking using Nengo_extras(0.1) raises errors "subsample" missing


#1

i am trying to run the Mnist_CNN spiking repo of hunse but got the errors “Conv2D’ object has no attribute 'subsample” .Dont know how to rectify this error. i am using keras version2.X with theano latest version and python3.6.

   # number of convolutional filters to use
    nb_filters = 32
    # size of pooling area for max pooling
    nb_pool = 2
    # convolution kernel size
    nb_conv = 3

    # convert class vectors to binary class matrices
    Y_train = np_utils.to_categorical(y_train, nb_classes)
    Y_test = np_utils.to_categorical(y_test, nb_classes)

    kmodel = Sequential()

    softlif_params = dict(
        sigma=0.002, amplitude=0.063, tau_rc=0.022, tau_ref=0.002)
   # model.add(Convolution2D(32, (3, 3), activation='relu', input_shape=(1,28,28), data_format='channels_first'))
    kmodel.add(GaussianNoise(0.1, input_shape=(img_rows, img_cols,1)))
    kmodel.add(Convolution2D(nb_filters, (nb_conv, nb_conv), padding='valid'))
    kmodel.add(SoftLIF(**softlif_params))
    kmodel.add(Convolution2D(nb_filters, nb_conv, nb_conv))
    kmodel.add(SoftLIF(**softlif_params))
    kmodel.add(AveragePooling2D(pool_size=(nb_pool, nb_pool)))
    kmodel.add(Dropout(0.25))

    kmodel.add(Flatten())
    kmodel.add(Dense(128))
    kmodel.add(SoftLIF(**softlif_params))
    kmodel.add(Dropout(0.5))
    kmodel.add(Dense(nb_classes))
    kmodel.add(Activation('softmax'))

    kmodel.compile(loss='categorical_crossentropy',
                   optimizer='adadelta',
                   metrics=['accuracy'])

    kmodel.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=nb_epoch,
               verbose=1, validation_data=(X_test, Y_test))
    score = kmodel.evaluate(X_test, Y_test, verbose=0)
    print('Test score:', score[0])
    print('Test accuracy:', score[1])

    save_model_pair(kmodel, filename, overwrite=True)

else:
    kmodel = load_model_pair(filename)
presentation_time = 0.2

model = nengo.Network()
with model:
    u = nengo.Node(nengo.processes.PresentInput(X_test, presentation_time))
    knet = SequentialNetwork(kmodel, synapse=nengo.synapses.Alpha(0.005))
    nengo.Connection(u, knet.input, synapse=None)

    input_p = nengo.Probe(u)
    output_p = nengo.Probe(knet.output)

    # --- image display
    image_shape = kmodel.input_shape[1:]
    display_f = image_display_function(image_shape)
    display_node = nengo.Node(display_f, size_in=u.size_out)
    nengo.Connection(u, display_node, synapse=None)

    # --- output spa display
    vocab_names = ['ZERO', 'ONE', 'TWO', 'THREE', 'FOUR',
                   'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE']
    vocab_vectors = np.eye(len(vocab_names))

    vocab = nengo.spa.Vocabulary(len(vocab_names))
    for name, vector in zip(vocab_names, vocab_vectors):
        vocab.add(name, vector)

    config = nengo.Config(nengo.Ensemble)
    config[nengo.Ensemble].neuron_type = nengo.Direct()
    with config:
        output = nengo.spa.State(len(vocab_names), subdimensions=10, vocab=vocab)
    nengo.Connection(knet.output, output.input)

A```
ttributeError Traceback (most recent call last)
in ()
5 with model:
6 u = nengo.Node(nengo.processes.PresentInput(X_train, presentation_time))
----> 7 knet = SequentialNetwork(kmodel,synapse=nengo.synapses.Alpha(0.001))
8 nengo.Connection(u, knet.input, synapse=None)
9

~\Anaconda3.0\lib\site-packages\nengo_extras\keras.py in init(self, model, synapse, lif_type, **kwargs)
79 self.add_data_layer(np.prod(model.input_shape[1:]))
80 for layer in model.layers:
---> 81 self._add_layer(layer)
82
83 def _add_layer(self, layer):

~\Anaconda3.0\lib\site-packages\nengo_extras\keras.py in _add_layer(self, layer)
99 for cls in type(layer).mro:
100 if cls in layer_adder:
--> 101 return layer_addercls
102
103 raise NotImplementedError("Cannot build layer type %r" %

~\Anaconda3.0\lib\site-packages\nengo_extras\keras.py in _add_conv2d_layer(self, layer)
112 filters, biases = layer.get_weights()
113 filters = filters[..., ::-1, ::-1] # flip
--> 114 strides = layer.subsample
115
116 nf, nc, ni, nj = filters.shape

AttributeError: 'Conv2D' object has no attribute 'subsample'

How to load,and create pickled object