loss

My classifier has very big loss and accuracy is always 0

落花浮王杯 提交于 2019-12-07 23:25:37
问题 I'm training a classifier to get a factor for an optimization. My data-set contains 800 samples as beginning (some are similar with just few modification). I developed my model with TensorFlow using GoogleColab environment. I have used a simple MLP for this problem, with 3 hidden layers each one has 256 nodes as first stage. I have also 64 classes 😬 . I have variable length inputs and I had fixed this problem with "-1" padding . with my actual features I know that I will get bad accuracy, but

Computing cosine_proximity loss between two outputs of the network

天大地大妈咪最大 提交于 2019-12-07 19:31:51
问题 I'm using Keras 2.0.2 Functional API (Tensorflow 1.0.1) to implement a network that takes several inputs and produces two outputs a and b . I need to train the network using the cosine_proximity loss, such that b is the label for a . How do I do this? Sharing my code here. The last line model.fit(..) is the problematic part because I don't have labeled data per se. The label is produced by the model itself. from keras.models import Model from keras.layers import Input, LSTM from keras import

'attributeError: 'Tensor' object has no attribute '_keras_history' during implementing perceptual loss with pretrained VGG using keras

我与影子孤独终老i 提交于 2019-12-06 15:54:45
I'm trying to implement the VGG perceptual loss for a model training for video inputs. I implemented the perceptual loss like the recommendation in the question AttributeError: 'Tensor' object has no attribute '_keras_history' : My mainModel looks like the following graph: Graph of mainModel The input size is (bathsize, frame_num, row, col, channel) . And I want to get the perceptual loss for the middle frame, that is, frame_num/2 . So, I implemented the following lossModel: lossModel = VGG19(weights='imagenet') lossModel = Model(inputs=lossModel.input,outputs=lossModel.get_layer('block3_conv4

Loss in Tensorflow suddenly turn into nan

匆匆过客 提交于 2019-12-05 20:27:01
When I using tensorflow, the loss suddenly turn into nan, just like: Epoch: 00001 || cost= 0.675003929 Epoch: 00002 || cost= 0.237375346 Epoch: 00003 || cost= 0.204962473 Epoch: 00004 || cost= 0.191322120 Epoch: 00005 || cost= 0.181427178 Epoch: 00006 || cost= 0.172107664 Epoch: 00007 || cost= 0.171604740 Epoch: 00008 || cost= 0.160334495 Epoch: 00009 || cost= 0.151639721 Epoch: 00010 || cost= 0.149983061 Epoch: 00011 || cost= 0.145890004 Epoch: 00012 || cost= 0.141182279 Epoch: 00013 || cost= 0.140914166 Epoch: 00014 || cost= 0.136189088 Epoch: 00015 || cost= 0.133215346 Epoch: 00016 || cost=

Loss does not decrease during training (Word2Vec, Gensim)

心已入冬 提交于 2019-12-04 18:24:36
What can cause loss from model.get_latest_training_loss() increase on each epoch? Code, used for training: class EpochSaver(CallbackAny2Vec): '''Callback to save model after each epoch and show training parameters ''' def __init__(self, savedir): self.savedir = savedir self.epoch = 0 os.makedirs(self.savedir, exist_ok=True) def on_epoch_end(self, model): savepath = os.path.join(self.savedir, "model_neg{}_epoch.gz".format(self.epoch)) model.save(savepath) print( "Epoch saved: {}".format(self.epoch + 1), "Start next epoch ... ", sep="\n" ) if os.path.isfile(os.path.join(self.savedir, "model_neg{

How to interpret increase in both loss and accuracy

岁酱吖の 提交于 2019-12-04 16:29:49
问题 I have run deep learning models(CNN's) using tensorflow. Many times during the epoch, i have observed that both loss and accuracy have increased, or both have decreased. My understanding was that both are always inversely related. What could be scenario where both increase or decrease simultaneously. 回答1: The loss decreases as the training process goes on, except for some fluctuation introduced by the mini-batch gradient descent and/or regularization techniques like dropout (that introduces

How to get results from custom loss function in Keras?

…衆ロ難τιáo~ 提交于 2019-12-04 04:31:25
I want to implement a custom loss function in Python and It should work like this pseudocode: aux = | Real - Prediction | / Prediction errors = [] if aux <= 0.1: errors.append(0) elif aux > 0.1 & <= 0.15: errors.append(5/3) elif aux > 0.15 & <= 0.2: errors.append(5) else: errors.append(2000) return sum(errors) I started to define the metric like this: def custom_metric(y_true,y_pred): # y_true: res = K.abs((y_true-y_pred) / y_pred, axis = 1) .... But I do not know how to get the value of the res for the if and else . Also I want to know what have to return the function. Thanks Mihai Alexandru

Keras Extremely High Loss

六月ゝ 毕业季﹏ 提交于 2019-12-02 00:54:29
问题 I'm trying to predict price by characteristics. I chose a pretty simple model, but it works very strange. Loss function is extremely high and I can't see where the problem is. Here is my model: # define base model def baseline_model(): # create model model = Sequential() model.add(Dense(62, input_dim = 62, kernel_initializer='normal', activation='relu')) model.add(Dense(31, kernel_initializer='normal', activation='relu')) model.add(Dense(15, kernel_initializer='normal', activation='relu'))

Keras - Loss and Metric calculated differently?

给你一囗甜甜゛ 提交于 2019-12-01 04:32:06
I have a model in Keras which I'm optimizing the mean squared error. However, if I use the same code as in losses.py from Keras in the metric, I get a different result. Why is this? As a metric: def MSE_metric(y_true, y_pred): return K.mean(K.square(y_pred, y_true)) For the model: model.compile(optimizer=SGD(lr=0.01, momntum=0.9), loss='MSE', metrics=[MSE_metric]) This results in a loss of 6.07 but an MSE_metric of 0.47 Remember - that if you use any kind of regularization - it affects your loss . Your actual loss is equal to: loss = mse + regularization and this is where your discrepancy

Keras - Loss and Metric calculated differently?

孤街浪徒 提交于 2019-12-01 02:10:32
问题 I have a model in Keras which I'm optimizing the mean squared error. However, if I use the same code as in losses.py from Keras in the metric, I get a different result. Why is this? As a metric: def MSE_metric(y_true, y_pred): return K.mean(K.square(y_pred, y_true)) For the model: model.compile(optimizer=SGD(lr=0.01, momntum=0.9), loss='MSE', metrics=[MSE_metric]) This results in a loss of 6.07 but an MSE_metric of 0.47 回答1: Remember - that if you use any kind of regularization - it affects