嘿,我用keras训练神经网络。我有14个类别。一切正常,没有错误。但是,当我查看结果时,发现最后3个受过训练的类别是完全错误的。 没有测试对象连接到这三个类别。
我已经更改了输入的顺序,但是模型不了解最后3个类别。
我还在最后一层使用了两种不同的激活功能(Sigmoid和softmax) 还有2种不同的优化程序(adam和sgd)
类别最多吗?
这是我的代码:
model = keras.models.Sequential()
model = Sequential()
model.add(Dense(units=50, input_dim = trainingsdaten.shape[1],
kernel_initializer='glorot_uniform',
bias_initializer='zeros',
activation='tanh'))
model.add(Dense(units=50, input_dim = 50,
kernel_initializer='glorot_uniform',
bias_initializer='zeros',
activation='tanh'))
model.add(Dense(output_dim = kategorien_train_one_hot.shape[1], input_dim=56,
kernel_initializer='glorot_uniform',
bias_initializer='zeros',
activation='sigmoid'))
sgd_optimizer = keras.optimizers.SGD(lr=lr, decay = decay, momentum = momentum)
model.compile(optimizer = 'adam',
loss = 'categorical_crossentropy',
metrics= ['accuracy'])
history = model.fit(trainingsdaten, kategorien_train_one_hot,
batch_size = batch_size, epochs=epochs,
verbose = verbose,
validation_split = validation_split)
答案 0 :(得分:0)
也许有一个小错误,您的第三个public class Movie
{
public string Name { get; set; }
public string Description { get; set; }
public string Classification { get; set; }
public string Studio { get; set; }
public DateTime? ReleaseDate { get; set; }
public List<string> ReleaseCountries { get; set; }
}
Movie movie = new Movie();
movie.Name = "Bad Boys III";
movie.Description = "It's no Bad Boys";
string included = JsonConvert.SerializeObject(movie,
Formatting.Indented,
new JsonSerializerSettings { });
// {
// "Name": "Bad Boys III",
// "Description": "It's no Bad Boys",
// "Classification": null,
// "Studio": null,
// "ReleaseDate": null,
// "ReleaseCountries": null
// }
string ignored = JsonConvert.SerializeObject(movie,
Formatting.Indented,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
// {
// "Name": "Bad Boys III",
// "Description": "It's no Bad Boys"
// }
层有一个Dense
,但是您的第二个input_dim = 56
层有50个节点。