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

Not working with tf.keras #25

Open
ppurwar opened this issue Mar 13, 2020 · 1 comment
Open

Not working with tf.keras #25

ppurwar opened this issue Mar 13, 2020 · 1 comment

Comments

@ppurwar
Copy link

ppurwar commented Mar 13, 2020

I tried the given example with tf 1.14.

`
from tensorflow.keras.models import Sequential
from keras_spp.spp.SpatialPyramidPooling import SpatialPyramidPooling
from keras.layers import Convolution2D, Activation, MaxPooling2D, Dense

model = Sequential()

model.add(Convolution2D(32, 3, 3, border_mode='same', input_shape=(3, None, None)))
model.add(Activation('relu'))
model.add(Convolution2D(32, 3, 3))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Convolution2D(64, 3, 3, border_mode='same'))
model.add(Activation('relu'))
model.add(Convolution2D(64, 3, 3))
model.add(Activation('relu'))
model.add(SpatialPyramidPooling([1, 2, 4]))
model.add(Dense(num_classes))
model.add(Activation('softmax'))`

Error received:

`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
6
7 # uses theano ordering. Note that we leave the image size as None to allow multiple image sizes
----> 8 model.add(Convolution2D(32, 3, 3, border_mode='same', input_shape=(3, None, None)))
9 model.add(Activation('relu'))
10 model.add(Convolution2D(32, 3, 3))

~/anaconda3/envs/py3_tf14/lib/python3.6/site-packages/tensorflow/python/training/tracking/base.py in _method_wrapper(self, *args, **kwargs)
455 self._self_setattr_tracking = False # pylint: disable=protected-access
456 try:
--> 457 result = method(self, *args, **kwargs)
458 finally:
459 self._self_setattr_tracking = previous_value # pylint: disable=protected-access

~/anaconda3/envs/py3_tf14/lib/python3.6/site-packages/tensorflow/python/keras/engine/sequential.py in add(self, layer)
152 raise TypeError('The added layer must be '
153 'an instance of class Layer. '
--> 154 'Found: ' + str(layer))
155
156 tf_utils.assert_no_legacy_layers([layer])

TypeError: The added layer must be an instance of class Layer. Found: <keras.layers.convolutional.Conv2D object at 0x7f8057c3ddd8>
`

@sinclairnick
Copy link

Hey @ppurwar, not sure if this is still relevant to you, but I've posted my implementation/modifications which make the SPP compatible with tf.keras.

See #26

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

2 participants