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

怎么将GHMCLoss应用于结构型数据[353130 rows x 115 columns] 11类 #2

Open
cfjcyc0301 opened this issue Aug 12, 2021 · 1 comment

Comments

@cfjcyc0301
Copy link

cfjcyc0301 commented Aug 12, 2021

大神,您好,我将GHMCLoss(layers.Layer)应用于结构型数据中,进行入侵检测
报错:ValueError: Could not interpret loss function identifier: 0.9288549423217773
请问需要怎么修改呢?

数据集是[353130 rows x 115 columns],有11类,用一维卷积,模型输入维度为
(None,11,1)
x_train_cnn.shape ---(247191, 115, 1)
x_validate_cnn.shape ---(35313, 115, 1)
x_test_cnn.shape ---(70626, 115, 1)

模型代码:
model = Sequential()

model.add(Conv1D(64, 4,strides=1, activation='relu',input_shape=(11, 1)))
model.add(Conv1D(64, 2,strides=1, activation='relu',padding="same"))
model.add(MaxPooling1D(pool_size=2,data_format='channels_last'))
model.add(Conv1D(128, 2,strides=2, activation='relu',padding="same"))
model.add(Conv1D(128, 2,strides=2, activation='relu',padding="same"))
model.add(MaxPooling1D(pool_size=2,data_format='channels_last'))

model.add(GlobalAveragePooling1D())
model.add(Dropout(0.2))

model.add(Dense(11,activation='softmax'))

model.compile(loss='categorical_crossentropy', optimizer='adam',metrics=['accuracy'])
monitor = EarlyStopping(monitor='val_loss', min_delta=1e-3,
patience=5, verbose=1, mode='auto')
history=model.fit(x_train_cnn,y_train,validation_data=(x_validate_cnn,y_validate),batch_size=512,
callbacks=[monitor],epochs=100)

请问gmh函数需要怎么改呢,我试了很多次不知道怎么改,本人编程基础比较薄弱,最近一直在解决这个难题,一直卡在这里,希望能得到您的回复,非常感谢。

@cfjcyc0301 cfjcyc0301 changed the title label_weights参数怎么设置 怎么将GHMCLoss应用于结构型数据[353130 rows x 115 columns] 11类 Aug 12, 2021
@HirataYurina
Copy link
Owner

我写GHMLoss的时候主要是应用在Faster rcnn代码中,如果是一维度卷积,例如处理时序信号类型数据,如果不是图像处理,可以把class_weights直接去掉。

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