Your network would try to fit perfectly and then you can use your special non-differentiable function just as a metric to measure how well is your network trained according to your rules. Is the value 110 still acceptable even though it should not be possible in theory?Īnyways, you can just use mae or mse as a loss. From your description it is not clear what would happen in this case: y_i = and pred =. Then you can start thinking how to write your loss. this answer How to restrict output of a neural net to a specific range?. Divide your labels by 100 and either use sigmoid activation on the outputs and or check e.g. There are multiple ways you can go about it. In that case, I would try to scale the output and the labels of the network such that they always lie in that range. įurthermore, from your question and comments I see the expected output should be between 0 and 100. This question might point you to the right direction. Next, do not forget, you need to use keras or tensorflow functions in your loss, so the used functions have the gradient defined and the chain rule can be applied. You need to rethink your loss or the whole problem. If you write your own loss, this is the first thing you need to keep in mind. Then it is possible to use the gradient to optimize the weights which is the whole point of gradient based optimization algorithms like Gradient Descent. My suggestion for a loss function: def N_distance(y_true, y_pred):įirst of all, your loss needs to be differentiable so that it is possible to compute the gradient with respect to the weights. History = (X, y, verbose=1, epochs=200, validation_split=0.1) (Dense(400, input_dim=n_inputs, kernel_initializer='he_uniform', activation='relu')) # self.earlystopping = callbacks.EarlyStopping(monitor="mae", My code is: class NeuralNetMulti(Regressor): Should I define a custom loss function, how should it look like, or how should I proceed? I am wondering which loss function to use in my Keras sequential model as to increase the explained accuracy the most. If y_i = and ypred_i = is a match, because all features have no more than 10 difference to its respective real features. I have an accuracy metric defined as follows:įor N predictions, the accuracy of the model will be the percentage of predicted samples such that: for each prediction and its respective true labels, all of the features are with no more than 10 difference.įor example, if y_i = and ypred_i = is not a match since the last feature has difference 11. I am using a Keras sequential model, a prediction output is of the shape (1, 5) (5 features).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |