且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

模型不学习

更新时间:2023-11-25 19:46:52

该模型是否使用了正确的模型?

一个人需要问的第一个问题是所使用的模型是否正确.该问题的模型使用了卷积层和密集层的混合体.但是该模型并没有真正遵循CNN的结构,而卷积层之后总是池化层.这是模型无法学习的原因吗?没必要...

The first question one needs to ask is if the model used is the right one. The model of the question uses a mixture of convolutional and dense layers. But the model does not really follow the structure of CNN whereas convolutional layers are always followed by pooling layers. Is it the reason why the model is not learning ? Not necessary ...

在分类问题中,对图像进行分类的方法有很多,各有其优缺点. FCNN不能达到良好的准确性,CNN却可以.但是训练CNN模型可能会耗费大量计算资源.这是转移学习发挥作用的地方.

In classification problems, there are different ways of classifying images each one with its pros and cons. FCNN does not achieve good accuracy, CNN does. But training a CNN model can be computation expensive. This is where transfer learning comes to play.

pacman示例使用转移学习.因此,如果您想复制该示例,请考虑遵循tfjs示例的github代码.这里的模型仅使用一个卷积层.关于如何编写转移学习模型.

The pacman example uses transfer learning. So if you want to replicate the example, consider following the github code of tfjs example. The model here uses only one convolutional layer. There are good tutorials on the official website of tensorflow as regard how to write CNN networks and transfer-learning models.

您使用了多少数据来训练模型?

深度学习模型通常需要大量数据.因此,除非模型看到很多带有标签的图像,否则其准确性非常低就不足为奇了.需要多少数据主要是艺术和设计问题,而不是科学问题.但是一般的经验法则是,有更多的数据,模型在预测中会更好.

Deep learning models in general needs a lot of data. So unless the model has seen a lot of images labelled, it won't be surprising if its accuracy is very low. How much data is needed is mostly a question of art and design than science. But a general rule of thumb, more there is data, better is the model in predicting.

调整模型

即使一个好的模型也需要调整其参数-时期数,批量大小,学习率,优化器,损失函数...更改这些参数并观察它们如何解释精度是实现良好精度的一个步骤.

Even a good model needs its parameter to be tuned - number of epochs, batchsize, learning rate, optimizer, loss function... Changing those parameters and observe how they account for the accuracy is a step in having good accuracy.

要指出的是,作为model.compile