J.Down
J.Down

Reputation: 775

Appending layers with previous in keras? - Conv2D' object has no attribute 'is_placeholder'

I seem to have some problem appending layers in keras.

Example:

import keras
from keras.layers.merge import Concatenate
from keras.models import Model
from keras.layers import Input, Dense
from keras.layers import Dropout
from keras.layers.core import Dense, Activation, Lambda, Reshape,Flatten
from keras.layers import Conv2D, MaxPooling2D, Reshape, ZeroPadding2D

input_img = Input(shape=(3, 6, 3))

conv2d_1_1 = Conv2D(filters = 32, kernel_size = (3,3) , padding = "same" , activation = 'relu' , name = "conv2d_1_1" )(input_img)
conv2d_2_1 = Conv2D(filters = 64, kernel_size = (3,3) , padding = "same" , activation = 'relu' )(conv2d_1_1)
conv2d_3_1 = Conv2D(filters = 64, kernel_size = (3,3) , padding = "same" , activation = 'relu' )(conv2d_2_1)
conv2d_4_1 = Conv2D(filters = 32, kernel_size = (1,1) , padding = "same" , activation = 'relu' )(conv2d_3_1)
conv2d_4_1_flatten = Flatten()(conv2d_4_1)

conv2d_1_2 = Conv2D(filters = 32, kernel_size = (3,3) , padding = "same" , activation = 'relu' , name = "conv2d_1_2")(input_img)
conv2d_2_2 = Conv2D(filters = 64, kernel_size = (3,3) , padding = "same" , activation = 'relu' )(conv2d_1_2)
conv2d_3_2 = Conv2D(filters = 64, kernel_size = (3,3) , padding = "same" , activation = 'relu' )(conv2d_2_2)
conv2d_4_2 = Conv2D(filters = 32, kernel_size = (1,1) , padding = "same" , activation = 'relu' )(conv2d_3_2)
conv2d_4_2_flatten = Flatten()(conv2d_4_2)


merge = keras.layers.concatenate([conv2d_4_1_flatten, conv2d_4_2_flatten])

dense1 = Dense(100, activation = 'relu')(merge)
dense2 = Dense(50,activation = 'relu')(dense1)
dense3 = Dense(1 ,activation = 'softmax')(dense2)


model = Model(inputs = [conv2d_1_1 , conv2d_1_2] , outputs = dense3)
model.compile(loss="crossentropy", optimizer="adam")

print model.summary()

Why am I not able to append my layers like this? The input is an image which i've manually separated in to shaped of (3,6,3)..

Upvotes: 2

Views: 2597

Answers (1)

Nassim Ben
Nassim Ben

Reputation: 11553

Your input isnt correct, you say it yourself, the input is your image. Change the way you create the model :

model = Model(inputs = input_img , outputs = dense3)

This should work.

Upvotes: 1

Related Questions