Chris Park
Chris Park

Reputation: 43

The value of loss is keeping fluctuating, questions about MLP model in general

I'm building MLP model for ML stuff and I have a basic questions about my model output.

Here's my source code and the result

epochs = 50
for epoch in range(epochs):
    for inputs, labels in train_loader:
        outputs = model(inputs)
        loss = criterion(outputs, labels)

        optimizer.zero_grad()
        loss.backward()
        optimizer.step()

    loss_values.append(loss.item())
    print(f'Epoch {epoch + 1}/{epochs}, Loss: {loss.item()}')

Epoch 1/50, Loss: 0.2941759526729584
Epoch 2/50, Loss: 0.2274172008037567
Epoch 3/50, Loss: 0.1548108160495758
Epoch 4/50, Loss: 0.09923569858074188
Epoch 5/50, Loss: 0.07782179117202759
Epoch 6/50, Loss: 0.08670808374881744
Epoch 7/50, Loss: 0.1000475212931633
Epoch 8/50, Loss: 0.08599527180194855
Epoch 9/50, Loss: 0.06509505957365036
Epoch 10/50, Loss: 0.0660080686211586
Epoch 11/50, Loss: 0.07633966952562332
Epoch 12/50, Loss: 0.06544400751590729
Epoch 13/50, Loss: 0.07453220337629318
Epoch 14/50, Loss: 0.0681438073515892
Epoch 15/50, Loss: 0.07069016247987747
Epoch 16/50, Loss: 0.05649592727422714
Epoch 17/50, Loss: 0.05515648424625397
Epoch 18/50, Loss: 0.05455780029296875
Epoch 19/50, Loss: 0.06591354310512543
Epoch 20/50, Loss: 0.06227065622806549
Epoch 21/50, Loss: 0.050895411521196365
Epoch 22/50, Loss: 0.05813339725136757
Epoch 23/50, Loss: 0.05856814980506897
Epoch 24/50, Loss: 0.056620728224515915
Epoch 25/50, Loss: 0.05406007170677185
Epoch 26/50, Loss: 0.05851085111498833
Epoch 27/50, Loss: 0.04691702872514725
Epoch 28/50, Loss: 0.036375436931848526
Epoch 29/50, Loss: 0.043669767677783966
Epoch 30/50, Loss: 0.047907356172800064
Epoch 31/50, Loss: 0.04583781585097313
Epoch 32/50, Loss: 0.044408515095710754
Epoch 33/50, Loss: 0.04572493955492973
Epoch 34/50, Loss: 0.0413966178894043
Epoch 35/50, Loss: 0.047711536288261414
Epoch 36/50, Loss: 0.046094246208667755
Epoch 37/50, Loss: 0.03935185819864273
Epoch 38/50, Loss: 0.036376748234033585
Epoch 39/50, Loss: 0.04275327920913696
Epoch 40/50, Loss: 0.04050033539533615
Epoch 41/50, Loss: 0.03928723931312561
Epoch 42/50, Loss: 0.038021307438611984
Epoch 43/50, Loss: 0.039322346448898315
Epoch 44/50, Loss: 0.03544142469763756
Epoch 45/50, Loss: 0.03906610235571861
Epoch 46/50, Loss: 0.03384337201714516
Epoch 47/50, Loss: 0.040965259075164795
Epoch 48/50, Loss: 0.038688428699970245
Epoch 49/50, Loss: 0.041332412511110306
Epoch 50/50, Loss: 0.03592131659388542

enter image description here

As you can see, the loss value is keeping decreasing in general, but it's still fluctuating at some points. This is my first time to build MLP model so I don't have any previous experience that I can comapre. Is it normal phenomenon? Should it be decreasing without fluctuating or it's kinda normal that I have little fluctuating?

Is it normal phenomenon? Should it be decreasing without fluctuating or it's kinda normal that I have little fluctuating?

Upvotes: 0

Views: 22

Answers (0)

Related Questions