简体   繁体   English

为什么我得到一条几乎是直线的 model 精度曲线?

[英]Why am I getting an almost straight line model accuracy curve?

在此处输入图像描述

I've plot my model accuracy curve in train and test data and I have obtained the following curve which looks rather unusual.我在训练和测试数据中有 plot 我的 model 精度曲线,我得到了以下看起来很不寻常的曲线。 What does this curve indicate?这条曲线说明了什么? Is it overfitting or underfitting?是过拟合还是欠拟合? Can anyone please help me, where am I going wrong?谁能帮助我,我哪里出错了? I am working on the ABIDE dataset.我正在处理 ABIDE 数据集。 I have 871 samples, I used cc400 parcellation which generated 76636 features.我有 871 个样本,我使用 cc400 分割生成了 76636 个特征。

I have provided the code snippet below:我提供了以下代码片段:

import tensorflow as tf
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
#create model
model = Sequential()

#add model layers
model.add(Dropout(0.2))
initializer_relu = tf.keras.initializers.HeUniform()
model.add(Dense(128, activation='relu', 
   kernel_initializer=initializer_relu, 
   kernel_regularizer=tf.keras.regularizers.l1(0.0001), input_shape= 
   (76636,)))
model.add(Dropout(0.2))
model.add(Dense(64, activation='relu', 
kernel_initializer=initializer_relu, 
kernel_regularizer=tf.keras.regularizers.l1(0.0001)))
model.add(Dropout(0.2))
initializer_sigmoid = tf.keras.initializers.GlorotUniform()
model.add(Dense(1, activation='sigmoid', 
kernel_initializer=initializer_sigmoid))

#compile model using mse as a measure of model performance
model.compile(optimizer='adam', loss='binary_crossentropy', 
metrics='accuracy')

from keras.callbacks import EarlyStopping
early_stopping_monitor = EarlyStopping(patience=3)
#train model
history= model.fit(X_train, y_train, validation_data=(X_test, y_test), 
batch_size=64 , epochs=20, callbacks=[early_stopping_monitor])

import matplotlib.pyplot as plt
print(history.history.keys())
# summarize history for accuracy
plt.plot(history.history[ 'accuracy' ])
plt.plot(history.history[ 'val_accuracy' ])
plt.title( 'model accuracy' )
plt.ylabel( 'accuracy' )
plt.xlabel( 'epoch' )
plt.legend([ 'train' , 'test' ], loc= 'lower right' )
plt.show()

The reason for straight accuracy line is that the model is not able to learn in 20 epochs.直线精度线的原因是 model 无法在 20 个时期内学习。 Because different features do not have similar ranges of values and hence gradients may end up taking a long time and can oscillate back and forth and take a long time before it can finally find its way to the global/local minimum.因为不同的特征没有相似的值范围,因此梯度最终可能会花费很长时间并且可以来回振荡并且需要很长时间才能最终找到全局/局部最小值。 To overcome the model learning problem, we normalize the data.为了克服 model 学习问题,我们对数据进行了归一化。 We make sure that the different features take on similar ranges of values so that gradient descents can converge more quickly我们确保不同的特征具有相似的值范围,以便梯度下降可以更快地收敛

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM