Search code examples
machine-learningneural-networkkerasloss-function

Keras logarithmic loss function


I have to apply following loss function with keras:

enter image description here

This is my code:

input_shape = self.s_dim[1:]
input_ = Input(shape=input_shape, name='input')
hidden = Dense(self.n_hidden, activation='relu')(input_)
out = Dense(3, activation='sigmoid')(hidden)

model = Model(inputs=input_, outputs=out, name="ar-model")
model.compile(loss='mean_squared_logarithmic_error', optimizer=SGD(lr=self.lr_ar))
return model

Does the loss function mean_squared_logarithmic_error fit here?


Solution

  • The mean_squared_logarithmic_error is something different than logarithmic loss, which is what you are looking for. Logarithmic loss is the same as crossentropy. You can use binary_crossentropy or categorical_crossentropy, dependent on your output.