Code Snippet:
def plot_filters(layer, x, y):
filters = layer.W.get_value()
...........
_plot_filters(model.layers[0], 8, 4)_
Error:
AttributeError: 'Conv2D' object has no attribute 'W'
====================================
I am using:
tensorflow==1.1.0rc0 Keras==2.0.2
Could version be a problem? What versions should be used?
Please read: https://github.com/fchollet/keras/wiki/Keras-2.0-release-notes
Also, code tells you everything. Change to layer.kernel, layer.bias
Still don't know how to solve the problem? Can you explain more details.
def plot_filters(layer, x, y):
# Change layer.W to layer.kernel since API variable name has changed in Keras 2
filters = layer.kernel.get_value()
...........
plot_filters(model.layers[0], 8, 4)
This feed helps me a lot!
As a Keras newbie, I was having trouble with deprecated codes.
layer.W is one of them.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.
I'm trying to visualise weights in the layers. Here's the code:
def plot_filters(layer, nrows = 1, ncols=1):
"""Plot the filters for convolution layer number (layer),
plotted in nrows by ncols layout"""
filters = layer.kernel.get_value()
fig = plt.figure()...
plot_filters(model.layers[0], 4, 4)
It's coming back with AttributeError: 'Variable' object has no attribute 'get_value'
@d8sconz Please check what kind of layer is model.layers[0], I believe it is Input layer or any layer except Convolutional layer.
Yes, that's the input layer. Same issue with layer[1] though which is a conv2D layer. I actually changed the code back to post to keep in line with original issue (layer[0]). I've gone with:
filters = model.layers[layer].get_weights()[0][:,:,0,:]
It gives me pretty visuals for both layer[0] and layer[1]. I'm not sure if it's what I actually need though, LOL. Still getting my head around it all.
hello evryone, I am trying the get the weight matrix, but im getting some error here
autoencoder.layers[3].kernel.get_value()
AttributeError: 'Variable' object has no attribute 'get_value'
im using keras(backend tensorflow).
Can someone please tell me whets wrong im doing?
getting 'Conv2D' object has no attribute 'nb_filter'
what's the issue?
Sorry @joelthchao ,as a Keras newbie,I still have some problem.
I can't understand clearly the meaning of ".W" in "layer.W" in Keras 1.
I found the source code of kears, and the "class _Conv(Layer):" just have the attribute "W_regularizer".
There isn't any attribute which names "W" in "class _Conv(Layer):".
What's wrong here?Thanks a lot!
AttributeError: 'Conv2D' object has no attribute 'layers'
Any help?
AttributeError: 'Conv2D' object has no attribute '_batch_input_shape'
What's wrong here?Thanks a lot!
Most helpful comment
Please read: https://github.com/fchollet/keras/wiki/Keras-2.0-release-notes
Also, code tells you everything. Change to
layer.kernel,layer.bias