0

My goal is to design and train a model to detect points of derivative discontinuity in a line profile. The input data of my model are 1D vectors, with some geometrical shapes [as shown in Fig 3], one adjacent to the other and such that their value in these points are (almost) the same. These profiles might be like line-circle, circle-circle, line-line etc. Since the input vector represents a real measure, everything that is not belonging to the aforementioned profiles is set to be 0. The length of the vector is "length".
So an example of the input might be [0,0,0,0,0,0,0,0, ........, profile1, profile2,..., 0,0,0,0]. (input vectors are normalized) I want to train my network to point out where the different profiles begin and end. My idea was to train a network whose output was a 1D vector of dimension "length", where the points of interest are labeled with "1" element (and setting the others as "0), making this a binary classification problem on multiple outputs. However, during training the accuracy is stuck to a value close to 0.5, regardless of the batch size and learning rates. Do you have any suggestions? If that is the case, is there a more suitable design for the network?

My network is:

# Define the neural network model
model = keras.Sequential([
        layers.InputLayer(input_shape=(length,)),
        layers.Dense(512, activation='relu'),
        layers.Dense(2048, activation='relu'),
        layers.Dense(length, activation='sigmoid')                                             
        # Output layer with 'length' units for probability estimate
])

model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# Compile the model

# Train the model
history = model.fit(x_train, y_train, epochs=num_epochs, batch_size=batch)```

[loss behavior with epochs][1]
[accuracy behavior with epochs][2]
[Example of training data vs predicted data: the "x" in the measured profile shows the points I want to predict, while the predicted windows fail to have peaks in these points][3]


  [1]: https://i.sstatic.net/DXqSz.png
  [2]: https://i.sstatic.net/zzXFF.png
  [3]: https://i.sstatic.net/QuN3e.png
11
  • Would you give the shapes of your input data and labels x_train.shape, y_train.shape, and the parameter length so we can check your model architecture and your data. Commented Jun 21, 2023 at 13:40
  • so in my case x_train is (2000, 400), y_train is (2000, 400) as well. They are of shape (num_samples, length). Anyway, num_samples can be any number. Commented Jun 22, 2023 at 7:00
  • I am trying to create your example by sitting x_train, y_train random values, but would you check these two arrays in your code if they contain any single nan values: print (np.sum(np.isnan(x_train)), np.sum(np.isnan(y_train))) Commented Jun 22, 2023 at 8:40
  • @user2586955 Thank you, I was sure not to have nan in my training set...but I was wrong. However, with correct x_train and y_train, now I have an accuracy that saturates at 0.5 during training, regardless of the learning parameters. Do you have any suggestions? Commented Jun 22, 2023 at 11:55
  • p.s. I also decreased learning rate along with epochs Commented Jun 22, 2023 at 12:00

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.