Skip to main content

All Questions

-1 votes
1 answer
45 views

implement a differentiable L0 regularizer to keras layer

What is the appropriate way to implement a differentiable variant of L0 regularizer (count the non-zero values in a Conv layer / matrix) to keras layer? I was thinking of using r(x) = tanh(abs(f*x)) ...
pas-calc's user avatar
  • 145
2 votes
0 answers
66 views

Can't replicate the behaviour of loss calculation in keras

I am working on a semantic segmentation problem where I have an input x ( CT image) to a deep learning model of shape (batch_size,1,256,256) and an output of shape (batch_size,2,256,256) where the ...
AAA_11's user avatar
  • 73
0 votes
0 answers
43 views

keras.models.load_model() reinitalized custom lossfunction to default arguments

I am tring to make and then save a model in python file, and then train the model in another file. This model uses a custom loss function that is in a seperate python file, so it can be imported into ...
Rob Binnenmars's user avatar
1 vote
1 answer
98 views

In Keras, how can I save and load a neural network model that includes a custom loss function?

I am having difficulty saving and reloading a neural network model when I use a custom loss function. For example, in the code below (which integrates the suggestions of the related questions here ...
SapereAude's user avatar
0 votes
0 answers
68 views

Custom Loss function Cannot squeeze axis=-1

I'm working on implementing a custom loss function in TensorFlow/Keras that incorporates both categorical cross-entropy loss and a penalty based on custom rules. These rules are designed to penalize ...
Pinguiz's user avatar
  • 123
0 votes
1 answer
107 views

Keras 3 Custom Loss Function to mask NaN

I am trying to build a custom Loss function on Keras 3, which would be used either in jax or torch backend. I want to mask out of y_pred and y_true all the indices where y_true is a certain value. ...
João Santos's user avatar
-1 votes
1 answer
210 views

How to interpret training and validation loss graph in Keras, is it a good fit? [closed]

I've trained a Keras model and obtained a graph with training and validation loss curves. The graph shows the following pattern: enter image description here Can someone help me interpret this graph? ...
DoomGuy's user avatar
1 vote
0 answers
26 views

Implementation of a Custom Loss Function in Keras for a Multi-item Newsvendor Problem with Substitutions

I want to implement a custom loss function in Keras for a Newsvendor. Problem (Demand forecasting and problem solving integrated in one ANN). The challenging part is that I have multiple products with ...
wanted curve's user avatar
0 votes
2 answers
72 views

Why generator loss using BinaryCrossEntropy with from_logits enabled?

From a simple vanilla GAN code I look from GitHub I saw this generator model with activation sigmoid: # Generator G = tf.keras.models.Sequential([ tf.keras.layers.Dense(28*28 // 2, input_shape = (...
Muhammad Ikhwan Perwira's user avatar
0 votes
0 answers
41 views

Custom fit function involving multiple outputs

class CustomModel(keras.Model): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.loss_tracker = keras.metrics.Mean(name="loss") self.mae_metric = keras....
inquisitive101's user avatar
0 votes
1 answer
290 views

Handling Class Imbalance in Multi-class Classification with Custom Loss Function [closed]

I am working on a multi-class classification problem in Python using advanced machine learning techniques. The dataset I am dealing with has a significant class imbalance issue, where some classes are ...
user avatar
2 votes
1 answer
373 views

TensorFlow Custom Loss Function Error: Node: 'gradient_tape/contrastive_loss/mul/BroadcastGradientArgs' Incompatible shapes [0,1] vs. [32,1]

I'm working on a Siamese network using TensorFlow and Keras. As the data is huge I am also trying to use the generator for batch loading. I have a custom contrastive loss function that I'm using for ...
Sahil Sinha's user avatar
0 votes
1 answer
710 views

Does Google Colab have its own random seed?

Does Google Colab have its own random seed that has nothing to do with TensorFlow or Numpy? I used the set_random_seed() function of Keras Utils and unify by 777 to the seed of the Numpy, TensorFlow, ...
h j's user avatar
  • 25
0 votes
1 answer
85 views

Keras custom loss with external data

Hello? I'm trying to write custom loss function with external data. My code is like that: classes_distributions = K.variable(np.full((A, A), 1.0 / A, dtype=float)) def my_loss(distributions): def ...
Дмитрий Шихов's user avatar
1 vote
0 answers
45 views

Why is the loss becoming NaN during training in my Keras model?

I am training a Keras model with complex input data using the CVNN library. However, during training, the loss becomes NaN after the first epoch. Here is the relevant code: import cvnn.layers as ...
Fahmida Afrin's user avatar

15 30 50 per page
1
2 3 4 5
31