deep-learning-keras-tensorflow icon indicating copy to clipboard operation
deep-learning-keras-tensorflow copied to clipboard

Whether the model can include the Embedding layer?

Open xiuzhilu opened this issue 6 years ago • 0 comments

My model is defined as follows: def create_model(): #input input_layer=Input(shape=(max_squence_len,),name="x_seq") embedding_layer=Embedding(input_dim=max_token_num,output_dim=embedding_dim) (input_layer) #conv layers convs=[] filter_sizes=[2,3,4] for fs in filter_sizes: l_conv=Conv1D(filters=50,kernel_size=fs,activation="relu")(embedding_layer) l_pool=MaxPooling1D(pool_size=2)(l_conv) l_pool=Flatten()(l_pool) convs.append(l_pool) merge=concatenate(convs,axis=1) out=Dropout(0.5)(merge) output=Dense(32, activation='relu')(out) output=Dense(units=31, activation='softmax')(output) model=Model([input_layer],output) adam = optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08, decay=0.0) model.compile(loss="categorical_crossentropy",optimizer=adam,metrics=['accuracy']) model=KerasClassifier(build_fn=self.create_model,batch_size=64,epochs=25) batch_size = [10, 20, 40, 60, 80, 100] epochs = [5,10,15,20,25,30] param_grid = dict(batch_size=batch_size, epochs=epochs) grid = GridSearchCV(estimator=model, param_grid=param_grid,cv=5) grid.fit(x_train,y_train) print("best_score:",grid.best_score_,"best_param:",grid.best_params_) But the program throws an error:TypeError: cannot deepcopy this pattern object can you help me solve this problem?

xiuzhilu avatar May 25 '19 13:05 xiuzhilu