Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [keras]

Keras is a popular, open-source deep learning API for Python built on top of TensorFlow and is useful for fast implementation. Topics include efficient low-level tensor operations, computation of arbitrary gradients, scalable computations, export of graphs, etc.

Filter by
Sorted by
Tagged with
0 votes
1 answer
323 views

Can I have 0 loss in the validation set and still have bad accuracy?

I am starting in the world of deep neural networks and doing a series of tests with a convolutional model, I have found the following case: The accuracy in the training set is much better (around 0.85)...
PicaR's user avatar
  • 314
1 vote
1 answer
36 views

What kind of model can be suitable for predicting 100 values from 25 values by using a Neural Network in TensorFlow?

Previously I used Sequential model for this problem, but later I read from the TensorFlow website that it is not suitable to use it. I'd like to have a NN model to predict 100+ values from the given ...
k-sky's user avatar
  • 13
0 votes
1 answer
116 views

Flatten layer description in "Hands-on Machine Learning"

I am currently studying from Hands-On Machine Learning with Scikit-Learn and TensorFlow. At some point in Chapter 10, the author demonstrates an MLP architecture to tackle the FashionMNIST problem: <...
Enk9456's user avatar
  • 105
0 votes
1 answer
498 views

LSTM model is producing really bad results for multiclass text classification for imbalanced small dataset

I am training a LSTM model on my current dataset to predict the multiclass categories - there are 18 mutually exclusive categories and the dataset has ...
Django0602's user avatar
0 votes
0 answers
2k views

ValueError: Input 0 of layer "model_12" is incompatible with the layer: expected shape=(None, 256, 256, 3), found shape=(256, 256, 3)

I am following this keras example with my own dataset, which has 3 classes. I load the images using ...
Javi's user avatar
  • 103
1 vote
1 answer
348 views

Regression to fill NA values

As a part of an exercise, I have the following dataset. Note that I have no idea where the values come from (are they based on something real or are they random numbers? Don't know...) ...
Davide_sd's user avatar
  • 111
1 vote
1 answer
753 views

How to compare $R^{2}$ of train and test data in a Deep Learning Neural Network Regression model?

I want to judge the goodness of my neural network regression model built using Keras Python Library. The problem is the following: from an input like (1000, 5000) so 1000 samples and each sample has ...
HelpNeederStudent's user avatar
1 vote
0 answers
106 views

Why is my segmentation model not returning a heat map?

I have implemented two CNN architectures to perform segmentations on medical images: the classic UNet and a modified version called the Attention UNet. I have been training the models on roughly 50,...
Noam's user avatar
  • 11
0 votes
1 answer
107 views

Export a detailed report with metrics after the training process of a Keras model

I have an image-segmentation model (.h5) which was trained using dice coefficient, recall and precision metrics. The model was trained using the ImageDataGenerator class with the following code: ...
Capdi's user avatar
  • 111
1 vote
1 answer
951 views

How can I write a Python program, that recognizes clapping sounds in an audio file, and saves them to disk?

I would like to write a Python program that takes an audio file as input, recognizes clapping sounds in it, then extracts these sounds into a file. My idea is the following: Get (or create) a dataset ...
Klangen's user avatar
  • 113
0 votes
2 answers
349 views

Is there a way to make keras custom test_step aware of the call being made from model.fit and model.evaluate

I am using keras custom model with custom train_step and test_step methods overwritten. Also, have a need to change certain margin used in the loss function, only for test dataset. In other words I ...
Nik's user avatar
  • 1
0 votes
1 answer
41 views

Sound Anomaly Detection

What is the recommended directory structure for sound anomaly detection using Keras CNN (Unsupervised) ? After converting the sound files into spectrograms. Code examples will be highly appreciated.
Cactus's user avatar
  • 1
2 votes
2 answers
3k views

How to arrange multiple multivariate time series of different length before passing it to Keras LSTM layer

I have a number of multivariate time series that are produced by the same kind of process but: are of significantly different lengths; each time series is an independent instance, and the ...
Xaume's user avatar
  • 192
0 votes
0 answers
191 views

KeyError: 'Resize' Error in converting from ONNX model to keras

I am trying to convert an ONNX model to a Keras model using onnx2keras, so that I can implement this: (https://machinelearningmastery.com/stacking-ensemble-for-deep-learning-neural-networks/) stacking ...
Thomas O'Brien's user avatar
0 votes
1 answer
770 views

Keras: LSTM model training - great differences in training results

This is an issue I've been encountering before and I was wondering what can be potential causes for this. Occasionally, training of an identical setup LSTM model ( using Keras ), on the same training ...
user2999349's user avatar
1 vote
1 answer
176 views

Keras class_weight for fit_generator

I am running a keras model using a fit_generator, with three classes, where each class is of the following: [1,0,0], [0,1,0], [0,0,1] Let's say the examples of ...
Never Nor's user avatar
  • 113
0 votes
1 answer
951 views

numpy.ndarray' object has no attribute 'batch' [closed]

I am building an image classifier using cnn using the following code- I am getting this error, despite making several changes- Kindly help me fix this error.
AMRITA DAS's user avatar
1 vote
1 answer
2k views

Input shape of dense layer in keras

I'm trying to build a new model ...
Joe's user avatar
  • 11
0 votes
1 answer
121 views

Define a custom distance between classes in Keras

How is it possible to make a classification with custom distance between classes in Keras? For example, let's say I need to classify betweenA1,...
EzrielS's user avatar
  • 323
0 votes
1 answer
183 views

What is the math behind the Keras Tokenizer() function?

I am doing an essay on the mathematics behind a text classifier with NLP and neural networks and I would like to know how exactly the TOKENIZER function of Keras works. Whether cosine similarity is ...
sara's user avatar
  • 3
0 votes
1 answer
143 views

Difference between class_weight and loss_weights arguments in TensorFlow/Keras

I am creating a neural network using TensorFlow (v2.9.2) for an imbalanced image dataset. While doing so, I noticed that model.compile() method has an argument <...
Harsh Khare's user avatar
0 votes
0 answers
299 views

Custom loss function for binary classificatio in Keras gets error: No gradients provided for any variable

I have a binary classification problem. However, I don't really care about fp and fn values. What I want to achieve is that the <...
Farzad's user avatar
  • 43
0 votes
1 answer
108 views

Not able to understand Transfer Learning with Vgg16

So, I have to work with Vgg16 in my semester group project, and was following this to do transfer learning. I don't understand CNN much, but am learning currently. The very first problem was that ...
royal_awake's user avatar
1 vote
1 answer
158 views

Feed output of neural networks into other network in tensorflow

I have two well trained neural networks, shown as: ...
Thomas Mikhail's user avatar
1 vote
0 answers
180 views

Embedding performing unexpectedly worse than multi-hot encoding

I'm pretty new to ML and have set up a Keras model with a number of categorical features of users & items to predict positive reactions. Each feature is a list of IDs from a database - i.e. ...
Tom's user avatar
  • 11
1 vote
1 answer
71 views

Using python AI mnist to recognize my picture, trained accuracy is 97.99%, but accuracy to my img is less than 20%

Questions like these are difficult to debug, but you'll hopefully find more help on datascience.stackexchange.com than here I see the suggestion that post in Data science is also a good option Using ...
DC con's user avatar
  • 111
0 votes
0 answers
1k views

` TypeError: int() argument must be a string, a bytes-like object or a number ` raised when fitting a multi input Keras model

I'm currently building a U-net model handling multiple input streams of data with Keras/Tensorflow's Functional API. Even though my model compiles, it raises a TypeError when I try to fit it. This ...
ydemers's user avatar
2 votes
1 answer
484 views

Keras model does not construct the layers in sequence

Every time I print the model summary it prints out the convlstm first and then batchnormalization at the end. Here is the output of model.summary ...
pwnkit's user avatar
  • 47
0 votes
1 answer
57 views

Conversion of DataFrame into array for Keras sequential Conv 1D model

I am new in the area of Sequential Conv 1D models. My question is the following: When I am converting the DataFrame (X_train) into an array, doesn't that impact ...
Homayra Alam's user avatar
0 votes
1 answer
46 views

Strange results from CNN in Keras

I have a binary classification problem. I designed a model with convolution kernels in first layers and then dense layers. As the output layer, however, I used a softmax layer with size 2, and then ...
Farzad's user avatar
  • 43
0 votes
0 answers
264 views

CNN-BERT Text Classification good results on train and val, but bad prediction on testing

I built a Keras model to predict hoax news and true news using the CNN-BERT Text Classification algorithm with Categorical Classification, with label 1 indicating a hoax and 0 indicating true news. ...
AccelUp's user avatar
0 votes
0 answers
184 views

How to use MinMaxScaler when X_train and X_test are different sizes

I'm using an LSTM through Keras to predict a time series. My inputs are the previous measurements of one time series(v1) at time 0-59 seconds and the goal is to predict the measurement of a different ...
user142789's user avatar
1 vote
1 answer
535 views

Proper way to reshape a image for training using CNN

I am new to Keras and facing some problems figuring out how to reshape the input image data properly. I have $16 x 16$ images, each with three layers, i.e., R, G, and B. The image data is in the form ...
Rameswar Sahu's user avatar
0 votes
1 answer
255 views

Model does not learn when using Keras 'flow_from_directory', but learns fine with 'image_dataset_from_directory'?

When classifying images with Keras, I am able to achieve a validation accuracy around 90-95%, however, I am trying to improve with the use of augmentation so have switched from ...
BDI's user avatar
  • 1
0 votes
0 answers
26 views

Keras Custom Layer Aware of Position in Network

I'm writing a custom Layer in TF/Keras (tf.keras.layers.Layer) for a CNN, and I need each layer to know its own depth in the model. Is there any way I can do this, ...
Liam F-A's user avatar
1 vote
1 answer
228 views

No improvement in test and training accuracy when training different optimizers

I am currently testing 5 different optimizers to see their training loss, and their testing accuracy. The optimizers are: AdaGrad, AdaDelta, RMSprop, Adam, Nadam. I am using a quite simple model with ...
heradsinn's user avatar
0 votes
1 answer
253 views

Setting shape of RaggedTensor with Known Shape

I'm working with RaggedTensors to manipulate a dense tensor. Something like this : ...
Liam F-A's user avatar
0 votes
1 answer
558 views

image_dataset_from_directory using a subset of sub-directories

I have downloaded the MINC dataset for material classification which consists of 23 cateogories. However, I am only interested in a subset of the categories (e.g. [wood, foliage, glass, hair]) Is it ...
Unknown's user avatar
1 vote
1 answer
3k views

Failed to convert a NumPy array to a Tensor (Unsupported object type float) in Python

I am trying to build a MLP with Keras and an error appears. I do not have experience with neural networks so it is difficult for me. When I run the code for the NN after some time it says: ...
alex martinez's user avatar
0 votes
0 answers
5k views

Keras Graph Execution Error When fitting the model

I am using this https://keras.io/examples/vision/conv_lstm/ code and providing my own dataset, which consists of frame size 550x775. But When I try to execute the ...
Muhammad Iqbal's user avatar
1 vote
1 answer
937 views

Determine batch size during `tensorflow.keras` Custom Class `call` method

I'm building a custom keras Layer similar to an example found here. I want the call method inside the class to be able to know what the ...
Jed's user avatar
  • 129
0 votes
2 answers
179 views

Accuracy decreases after adding more samples

I'm working on a multiclass text classification task (5 classes). I've 2 types of datasets: regular (~22000 samples) dataset of duplicates (~19000 samples) I've written a logic that labels them all. ...
Ben's user avatar
  • 209
0 votes
0 answers
133 views

LSTM accuracy VS F1-score

I am trying to do multi-classification on imbalanced data with 3 classes. The imbalance is something like 6:1:3. The total amount of samples is 7000. I use LSTM, and Word2Vec to vectorize the data. ...
Eli Halych's user avatar
1 vote
0 answers
237 views

Keras NLP TransformerDecoder MultiHeadAttention Value Error

Recently I have been working on a MIDI Music Generator using the TransformerEncoder & TransformerDecoder layers found in the Keras NLP library. There is not much info/help on these layers which is ...
Cameron A's user avatar
1 vote
0 answers
31 views

What is exactly the loss value evaluated at every epoch of training?

If I compile a certain model with adam optimizer and I have used a batch size of 32 in the fit function, When I start training the model, I get a loss value at the end of every epoch. I understand ...
AAA's user avatar
  • 35
1 vote
0 answers
74 views

kernels are learnable in tf.nn.conv2d?

I am implementing a custom convolution layer as follow to understand the customizable layer: ...
David's user avatar
  • 131
0 votes
1 answer
34 views

Is this a case for too much dimensionality? 1881 samples, 2562 features

I have been working on creating a multi-class classification model for medical data. I have 1881 samples, 2562 features each, and 6 classes total. My distribution of classes is as follows: {1: 83, 2: ...
StrWrs_Nerd's user avatar
0 votes
0 answers
28 views

Beginner: mnist converted to jpeg model not accurate

As a beginner I'm trying to understand the Tensorflow quickstart tutorial . Basically the page gives you a series of buttons to click after wich you are told you achieved a 98% accuracy. This is not ...
Rutger Moody's user avatar
0 votes
0 answers
1k views

Invalid argument error: logits and labels must be broadcastable

Whenever I try to execute this vgg16 code I get an error like this: ...
Pratik Pradhan's user avatar
2 votes
1 answer
168 views

How to Interpret Loss Curves?

My CNN model have one hidden layer with accuracy of 0.515. How can I Interpret the loss curve?
yellowAndriod's user avatar

1 2 3
4
5
55