Closed mbarraghi closed 3 years ago
Hey @mbarraghi
Could you use keras.layers.InputLayer
instead of keras.Input
as the first layer and see if that works? It is suggested that with a Sequential
model we used an InputLayer
and with the Functional API we use the Input
layer.
@mbarraghi, This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
@mbarraghi, Can you please let us know if this comment has resolved your issue? Thanks!
This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.
hi I work on a code and faced this error. I would be grateful if you could help me class SOMLayer(Layer): def init(self,out_dim,kernel, strides,map_size,input_dim,kwargs): super(SOMLayer,self).init(kwargs) self.out_dim = out_dim self.kernel = kernel self.strides = strides self.map_size = map_size self.input_dim = input_dim self.input_side = input_dim[0] self.max_patches = math.ceil((self.input_side - self.kernel) // 2 +1) self.max_patches = self.max_patches*self.max_patches
class Sample(Layer): def init(self,out_dim, kwargs): self.out_dim = out_dim super(Sample,self).init(kwargs)
(train_images , train_labels), (test_images , test_labels) = mnist.load_data()
train_images = train_images.reshape((60000 , 28 * 28))
train_images = train_images.astype('float32') / 255
test_images = test_images.reshape((10000 , 28 * 28))
test_images = test_images.astype('float32') / 255 train_labels = to_categorical (train_labels) test_labels = to_categorical (test_labels)
x_train= train_images[:4000]
x_validation=train_images[4000:]
x_labels = train_labels[:4000]
y_validation = train_labels[40000:]
model1 = Sequential( [ keras.Input(shape=(28,28)), SOMLayer(100, kernel = 10, strides = 2,map_size = 20, input_dim=(28,28)),
Sample(out_dim = 10),
SOMLayer(25, kernel = 6, strides = 1,map_size = 15,input_dim=(10,10)), Sample(out_dim = 5),
SOMLayer(1, kernel = 5, strides = 1,map_size = 8,input_dim=(5,5)) ] )
TypeError Traceback (most recent call last)