Machine learning 什么';这个CNN框架结构有什么问题?

Machine learning 什么';这个CNN框架结构有什么问题?,machine-learning,keras,conv-neural-network,Machine Learning,Keras,Conv Neural Network,其中,输入为941个实例,具有43个标量特征,输出为0到1之间的连续变量。目前的错误是 Anger_train = Anger_train.to_numpy().reshape(Anger_train.shape[0], 1, Anger_train.shape[1]) Anger_test = Anger_test.to_numpy().reshape(Anger_test.shape[0], 1, Anger_test.shape[1]) def getModel(): m

其中,输入为941个实例,具有43个标量特征,输出为0到1之间的连续变量。目前的错误是

Anger_train = Anger_train.to_numpy().reshape(Anger_train.shape[0], 1, Anger_train.shape[1])
Anger_test = Anger_test.to_numpy().reshape(Anger_test.shape[0], 1, Anger_test.shape[1])
def getModel():
    
    model = Sequential()

    model.add(Conv1D(64,1, activation='relu', input_shape=(941,1,43)))
    model.add(Conv1D(64,1, activation='relu'))
    model.add(MaxPooling1D())
    
    

    model.add(Flatten())
    
    model.add(Dense(100, activation='relu'))
    model.add(Dropout(rate=0.5))
    model.add(Dense(1, activation='sigmoid'))

    model.compile(loss='mean_squared_error', optimizer="sgd")
    
    return model

不要在输入形状中包含批次大小。您发布的代码显然也不是实际产生错误的代码…因为我更改了输入形状,现在显示了由1减去3导致的负尺寸大小…这是因为您的输入形状有一个(1,单个)时间步长。为什么使用卷积?这整件事对我来说毫无意义。不要在输入形状中包含批量大小。您发布的代码显然也不是实际产生错误的代码…因为我更改了输入形状,现在显示了由1减去3导致的负尺寸大小…这是因为您的输入形状有一个(1,单个)时间步长。为什么使用卷积?这整件事对我来说毫无意义。
ValueError: Input 0 of layer maxpooling1D is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 1, 43, 256)