0
$\begingroup$

I'm working on predicting 4 numeric values basing on signal spectrum (spectrum is represented as an array of 800 numeric values in scale 0 to 1). The input values are scaled by using StandardScaler. Here's an example of the plotted input: Plotted input for model

The outputs are 4 values which are in the following ranges:

  • n_eff: 1.44 to 1.45
  • period: 535e-9 to 540e-9
  • delta_n_eff: 1e-5 to 1e-4
  • X_z: 0.01 to 0.99

Before training of the model, the output values are rounded to 3 decimal places and scaled (delta_n_eff is multiplied by 1e3 and period is multiplied by 1e6)

The model has such structure:

Model: "sequential"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Layer (type)                    ┃ Output Shape           ┃       Param # ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ conv1d (Conv1D)                 │ (None, 799, 550)       │         1,650 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ max_pooling1d (MaxPooling1D)    │ (None, 399, 550)       │             0 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ conv1d_1 (Conv1D)               │ (None, 398, 40)        │        44,040 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ max_pooling1d_1 (MaxPooling1D)  │ (None, 199, 40)        │             0 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ conv1d_2 (Conv1D)               │ (None, 198, 40)        │         3,240 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ max_pooling1d_2 (MaxPooling1D)  │ (None, 99, 40)         │             0 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ conv1d_3 (Conv1D)               │ (None, 98, 125)        │        10,125 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ max_pooling1d_3 (MaxPooling1D)  │ (None, 49, 125)        │             0 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dropout (Dropout)               │ (None, 49, 125)        │             0 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ flatten (Flatten)               │ (None, 6125)           │             0 │
├─────────────────────────────────┼────────────────────────┼───────────────┤
│ dense (Dense)                   │ (None, 4)              │        24,504 │
└─────────────────────────────────┴────────────────────────┴───────────────┘
 Total params: 83,559 (326.40 KB)
 Trainable params: 83,559 (326.40 KB)
 Non-trainable params: 0 (0.00 B)

And it's implemented like that:

        input_shape = (800, 1)
        output_dim = 4

        # 4 OUTPUTS, 800 INPUTS

        model = Sequential([
            Input(shape=input_shape),
            Conv1D(filters=550, kernel_size=2, activation='relu'),
            MaxPooling1D(pool_size=2),
            Conv1D(filters=40, kernel_size=2, activation='relu'),
            MaxPooling1D(pool_size=2),
            Conv1D(filters=40, kernel_size=2, activation='relu'),
            MaxPooling1D(pool_size=2),
            Conv1D(filters=125, kernel_size=2, activation='relu'),
            MaxPooling1D(pool_size=2),
            Dropout(0.15),
            Flatten(),
            Dense(output_dim, activation='linear'),
        ])

        model.compile(optimizer='adam',
                      loss='mean_squared_error', metrics=['mse', 'mae'])

Each epoch lasts around 2 min. After 45 epochs I got such results: loss mse mae

Calculated R2 had value -2.6489172656653017.

Calculated MAE had value 0.014245257581615895.

Calculated root MSE had value 0.031099013924338864.

What can I do to obtain stable validation plots and better value of R2? I tried to change filters parameter in models or add dropout layer but it ends up with worse values of metrics.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.