0

我的数据具有分配给四个类别之一的条目,并且我正在对其进行前馈神经网络训练。到目前为止,我有以下代码,这给了我整体的准确性。但我想获得每个班级的准确性。

np.random.seed(0)

number_of_features = 1

train_features = punct_array
test_features = punct_gold_array


# Start neural network
network = models.Sequential()

# Add fully connected layer with a ReLU activation function
network.add(layers.Dense(units=16, activation='relu', input_shape=(number_of_features,)))

# Add fully connected layer with a ReLU activation function
network.add(layers.Dense(units=16, activation='relu'))

# Add fully connected layer with a sigmoid activation function
network.add(layers.Dense(units=4, activation='softmax'))



# Compile neural network
network.compile(loss='sparse_categorical_crossentropy', # Cross-entropy
                optimizer='adam', # Root Mean Square Propagation
                metrics=[metrics.mae, metrics.categorical_accuracy])



# Train neural network
history = network.fit(train_features, # Features
                      Label_array, # Target vector
                      epochs=40, # Number of epochs
                      verbose=1, # Print description after each epoch
                      batch_size=16, # Number of observations per batch
                      validation_data=(test_features, goldLabel_array))

这些类被标记为 0、1、2 和 3。

4

0 回答 0