You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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?
The text was updated successfully, but these errors were encountered: