Kaggle airbus ship detection challenge.How to deal with class imbalance?

My model always predict under probability 0.5 for all pixels. I dropped all images without ships and have tried focal loss,iou loss,weighted loss to deal with imbalance . But the result is...

Make custom loss function for Keras

I would implement custom Keras loss function for focal loss which explained in this paper; however, I have to get the weight of the trainable layers. So, is there any way to read the weight of the...

Keras get the number of image in batch from y_pred in side custom loss function

In this loss function, I need to create full metrics depends on the number of images in batch and size of the image. However, I can get the image size from y_pred but no the batch size because it...

Confusions regarding RetinaNet

I have been studying RetinaNet recently. I read the original paper and some related ones and wrote a post sharing what I have learnt:...

Focal Loss in RetinaNet

Can someone please explain in simple what is focal loss in RetinaNet from this below 2 paper Feature Pyramid Networks for Object Detection Focal loss for Dense object detection

How do I fix AttributeError: 'series' object has no attribute 'columns'? in python

I'm creating a bunch of excel sheets using pandas apart from I can only create the first 3 before the fourth one throws an error. I've identified that the error is in the column names somewhere,...

Is there a way to initialise keras kernels for unbalanced classification?

I'm dealing with binary unbalanced classification and I've been using the focal loss in order to improve my results. It is mentioned in the original paper that the weights must be initialised...

Categorical focal loss on keras

I would like to use categorical focal loss in tf/keras. Binary Focal loss works for me but not the code I found for categorical f.l. Does someone have this ?

How to perform gradient accumulation WITH distributed training in TF 2.0 / 1.14.0-eager and custom training loop (gradient tape)?

Background: I have a model and I'm trying to port it to TF 2.0 to get some sweet eager execution, but I just can't seem to figure out how to do distributed training (4 GPU's) AND perform gradient...

Initialize the bias term of the last layer

I was reading the this blog about focal loss. In the section Focal Loss Trick it says: Facebook AI Research used is to initialize the bias term of the last layer to some non-zero value such that...

Implementation of Focal loss for multi label classification

trying to write focal loss for multi-label classification class FocalLoss(nn.Module): def __init__(self, gamma=2, alpha=0.25): self._gamma = gamma self._alpha = alpha def...

Use of 1-a weight in categorical focal loss

I am trying to use focal loss in keras/tensorflow with multiple classes which leads to use Categorical focal loss I guess. I have found some implementation here and there or there. As far as I get...

How does TensorFlow/Keras's class_weight parameter of the fit() function work?

I do semantic segmentation with TensorFlow 1.12 and Keras. I supply a vector of weights (size equal to the number of classes) to tf.keras.Model.fit() using its class_weight parameter. I was...

ValueError: Unknown loss function:focal_loss_fixed when loading model with my custom loss function

I designed my own loss function. However when trying to revert to the best model encountered during training with model = load_model("lc_model.h5") I got the following...

Custom loss function (focal loss) input size error in Keras

I am using a neutral network to do multi-class classification. There're 3 imbalanced classes so I'd like to use the focal loss to handle the in-balance. So I use custom loss function to fit in...

modification from classification loss to regression loss

General I am following this repo for object detection https://github.com/yhenon/pytorch-retinanet Motivation Object detection networks usually perform 2 tasks.For every object in the image output...

Tensorflow/Keras: volatile validation loss

I've been training a U-Net for single class small lesion segmentation, and have been getting consistently volatile validation loss. I have about 20k images split 70/30 between training and...

LightGBM - Binary Classification using train API

I have a binary classification problem which I'm trying to solve using LightGBM's train and cv APIs. First I have tuned the hyperparameters by using hyperopt together with an objective function...

Tensorflow, Keras: In a multi-class classification, accuracy is high, but precision, recall, and f1-score is zero for most classes

General Explanation: My codes work fine, but the results are wired. I don't know the problem is with the network structure, or the way I feed the data to the network, or anything else. I am...

How to handle class imbalance in multi-label classification using pytorch

We are attempting to implement multi-label classification using CNN in pytorch. We have 8 labels and around 260 images using a 90/10 split for train/validation sets. The classes are highly...

How to use custom loss function for keras

I have recently came across the Focal loss function and heard it's mainly used in imbalanced dataset. So i just gave it a try on Cifar10 dataset by using this simple Focal loss function i found...

TF object detection API detection model retraining: "object_detection.protos.TrainConfig" has no field named "fine_tune_checkpoint_version"

I'm retraining ssd_mobilenet_v2_coco_2018_03_29 using Tensorflow Object Detection API and I get this particular error on both Windows and Ubuntu environments. My environment below is Windows 10...

Tensorflow 2.2 [predictions must be >= 0] [Condition x >= y did not hold element-wise:] [x (dense_1/Sigmoid:0) = ]

I am training a Binary detection architecture using TensorFlow 2.2 and Keras. Previously, I had this working if I loaded the data in the same script as the training of the model. However, when I...

How to Use Class Weights with Focal Loss in PyTorch for Imbalanced dataset for MultiClass Classification

I am working on Multiclass Classification (4 classes) for Language Task and I am using the BERT model for classification task. I am following this blog as reference. My BERT Fine Tuned model...

Load keras model with custom_metrics and custom loss

I have created a keras model by sub classing keras.model. I have also used custom loss (focal loss), custom metrics (sub classing the keras.metrics) and learning rate decay. I have trained the...

TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type int64 of argument 'x'

after this code i am getting the error in categoricalfocalloss i m not getting whereint64 error is coming def categorical_focal_loss(gamma=2., alpha=.25): def...

Imbalanced Image Dataset (Tensorflow2)

I'm trying to do a binary image classification problem, but the two classes (~590 and ~5900 instances, for class 1 and 2, respectively) are heavily skewed, but still quite distinct. Is there any...

Keras custom loss function to ignore false negatives of a specific class during semantic segmentation?

See EDIT below, the initial post almost has no meaning now but the question still remains. I developing a neural network to semantically segment imagery. I have worked through various loss...

(Pytorch)AssertionError: Invalid type <class 'NoneType'>

I tried to retrain LoFTR(2021 CVPR paper), but I have faced some bugs. I'm a newcomer of deep-learning, please bear with me. The full traceback is: Traceback (most recent call last): File...