Skip to main content

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
2 answers
321 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 ...
0 votes
1 answer
535 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 ...
0 votes
1 answer
92 views

Pre-trained CNN model makes Poor Predictions on Test Images Dataset

I have tried using several a pretrained models (MobileNet) for multiclass predictions. There are 42 classes and the distributions of the images are even across the 42 classes. This is my code: ...
1 vote
2 answers
298 views

Keras input for multivariate classification with LSTM using current features and previous timesteps features and y values

I am working on a multivariate binary classification problem. What I want to do is to predict a binary classification given the features at the current timestep and the data (features+real ...
2 votes
1 answer
5k views

Using LSTM to predict binary classification - accuracy stuck at 50% - how to use statefulness

I am trying to use an LSTM model to make binary classifications; however when I train the model the loss stays around 0.69 (ie. -$\ln(0.5)$) and the accuracy at 0.5, which suggests to me the model is ...
0 votes
0 answers
13 views

Getting nearly 100% accuracy using Binary Classification in Tensorflow but incredibly wrong prediction levels for email messages

I'm creating a Chrome Extension to read user emails via Gmail's API, and then passing in user emails to a trained Keras model in Flask to determine whether the email was written by an AI or a Human, ...
0 votes
0 answers
8 views

Overfitting - Imbalance Classification using Deep-feed forward network

I have an unbalanced dataset, so I used SMOTEENN on the training set to resample, after training DFF,i could see the model is overfitting, could someone help me solve this? Thank You. ...
2 votes
1 answer
21 views

Custom loss function in python

I am trying to implement a custom loss function inspired by https://arxiv.org/pdf/2305.10464.pdf. That is: $ L(\mathbf{x}) = (1-y) \left\lVert \mathbf{x_{true} - \mathbf{x_{pred}}} \right\rVert^2 + y \...
1 vote
2 answers
94 views

Probabilities in KERAS

I'm struggle with a problem OF class probabilities (binary, 0 and 1). Dont know why but after 100 epoches the probabilities became 0 or 1 (like the class to predict). Maybe something is not working ...
1 vote
1 answer
85 views

Error while writing perceptron algorithm binary classifier

I am a beginner and I am designing an binary classifier using Perceptron algorithm using FASHION-MNIST dataset. While designing the same I have written the following code: ...
1 vote
1 answer
115 views

How could you build a Neural Network with the same weights for different nodes in the same layer

The structure I'm imagining is like the one in the image bellow where the output is softmax. For the hidden layer we would have $$Z_1 = W_{11}^{[1]}x_2 + W_{12}^{[1]}x_2$$ $$Z_2 = W_{21}^{[1]}x_2 + ...
0 votes
2 answers
838 views

How to feed training set labels into Keras LSTM

I’m implementing an LSTM with Keras and I know that I have to reshape the training dataset in a 3D object. Basically I have a ...
0 votes
1 answer
326 views

Cars classification using pre-trained models

I have a bunch of images and I need recognise some objects on them: Analyse the type of vehicle (car, truck, tanker), make, model, colour. Check if there are persons on the image. I would like to ...
0 votes
1 answer
114 views

Custom Loss Function in Tensorflow for UNet

I am working on a Segmentation task, where I planned to use U-Net for the input_image of shape (224,224,3), the output should be the mask image of shape ...
1 vote
1 answer
194 views

Making outputs of sub-models the inputs of other models LSTM

I'm trying to create a neural network that is composed of different sub-models. Each sub-model have their own inputs, which some of them can be shared between the sub-models. For example, sub-model 1 ...
4 votes
2 answers
7k views

Saving and loading keras.callbacks.History object with np.save and np.load

I have been saving my training history in keras as follows: ...
0 votes
0 answers
32 views
+50

Tensorflow SegNet architecture

I was unable to find a complete description of the SegNet architecture for image segmentation (specifically, the decoder layers). Therefore, I would like to clarify the correctness of my ...
2 votes
3 answers
143 views

Why does only Adam optimiser perform well in my case?

I am trying to classify texts into categories (one text can have multiple categories), to do this I used one-hot encoded labels (with ...
6 votes
1 answer
8k views

Keras - Implementation of custom loss function with multiple outputs

I am trying to replicate (a way smaller version) the AlphaGo Zero system. However, in the network model, I am having a problem. The loss function I am supposed to implement is the following: $$l = (z -...
3 votes
1 answer
1k views

How to identify/recognize that a sentence about talks about future?

Brief Introduction: I have a report/paragraph in which there are sentences with reference to future plans/outlooks/expectations for a particular entity. I want to extract all such sentences for now. ...
1 vote
1 answer
428 views

setting class weights for imbalanced dataset, how using EarlyStopping?

I want to train a CNN with Early Stopping (Keras). The data set is imbalanced, so I have set class_weights to 'balanced' like follows: ...
1 vote
2 answers
356 views

Facial recognition on offline images

I want to do facial recognition on wide varieties of images captured at various ages of my family members. Below are some of the questions I have. If a person uses glasses of different types, do I ...
0 votes
1 answer
99 views

Using text classification for system calls

I'm working on a project in which I should classify System calls sequences, my dataset is represented as sequences of integers (from 1 to 340). To do the classification I have inspired from Text ...
1 vote
1 answer
320 views

Reason for Training and test loss sudden increment after some epochs keras

We know that if training and test loss are different from each other, our model is over-fitting. However, if both get high after some epochs, how can we justify it? One way to solve it is to reduce ...
0 votes
2 answers
1k views

Problems with shape of Conv1D on Keras

I have some problems with layers construction on Keras. I explain the whole problem: I have a feature matrix, with dimensions: 2023 (rows) x 65 (features); I tried to build a CNN, with Conv1D as ...
1 vote
1 answer
2k views

How to quantize weights in forward pass during training in Keras?

In Keras, I would like to train a network with binary weights in the manner of Coubariaux, et al., but I cannot figure out where the quantization (binarization) should occur within the code. A core ...
1 vote
1 answer
10k views

Tensorflow Model fitting ValueError: Layer sequential expects 1 inputs, but it received 520 input tensors

I am trying to train a model using Tensorflow. I am reading a huge csv file using tf.data.experimental.make_csv_dataset Here is my code: Imports: ...
2 votes
1 answer
2k views

While retraining a pretrained model, getting: ValueError: Input 0 is incompatible with layer flatten_1: expected min_ndim=3, found ndim=2

My model summary is: ...
0 votes
1 answer
134 views

Keras, re use convoluted layers training for various flattened layers training

I want to train a range of models, that are very similar; the convoluted layers are the same but the flattened part changes. For example; different density, initially I have ...
1 vote
1 answer
4k views

Keras: ValueError: Input 0 is incompatible with layer lstm_1: expected ndim=3, found ndim=2

I am using Keras functional API to write an LSTM model but It throwing an error can somebody please help below is the code for the model the output shape is 65. I am using Keras 2.2.4 and TensorFlow 1....
0 votes
1 answer
10 views

Connecting Flatten layer to Dense layer

I'm struggling with my neural network. In short, I need to recreate a model from anywhere on the internet, I've found a model that combines BiLSTM, LSTM and GRU. However, based on the error I got when ...
1 vote
1 answer
546 views

Image.py warning messages

I got the following warning messages when calling the 'model.fit_generator' function on keras: ...
0 votes
2 answers
7k views

Validation Accuracy Not Changing

As the title states, my validation accuracy isn't changing when I try to train my model. I've built an NVIDIA model using tensorflow.keras in python. I have absolutely no idea what's causing the issue....
3 votes
2 answers
2k views

Keypoint detection from an image using a neural network

I am trying to design and train a neural network, which would be able to give me coordinates of certain key points in the image. Dataset I've got a dataset containing 1800 images similar to these: ...
1 vote
1 answer
343 views

Loss and Metrics for COCO Keypoints

I am using Keras to train different models on the COCO keypoints dataset. All of the models I am working with are used for image segmentation, so they output heatmaps corresponding to the labels. All ...
1 vote
2 answers
362 views

Why does the classic Neural Network perform better than LSTM in Sentiment Analysis

My goal is to predict the polarity of some reviews (negative, positive or neutral). I tried two different neural networks: ...
2 votes
1 answer
376 views

YOLO v3 complete architecture

I am attempting to implement YOLO v3 in Tensorflow-Keras from scratch, with the aim of training my own model on a custom dataset. By that, I mean without using pretrained weights. I have gone through ...
0 votes
1 answer
125 views

Issues related to the code for ROI pooling from the feature map

I am trying to do ROI pooling on the feature map obtained from the VGG layers but I don't know how to code this layers. Can anybody help me out? Here is my VGG layers: ...
0 votes
1 answer
497 views

How to find the class name of a new image from the pre-trained model

I would just like to get the class names of the predictions. I can get the class names on the images that I trained the model. But if I predict an image (say which is not trained but already belongs ...
0 votes
1 answer
149 views

Help required to implement the below model using Bi-GRU

As you can see in above images I need to model Bi-GRUs stacked as shown in table which takes input (N,1,64) and outputs (N,204). The input data is binary number stream and so is output data. Can ...
3 votes
3 answers
509 views

How to find optimized x values (input features) after training in deep learning?

I did deep learning training by Keras. I have done the training part by model.fit If I do model.predict, it only gives me y value. But I want to know x (input features) that gives the best y value, ...
0 votes
1 answer
229 views

NAN in keras neural network results

I am creating a neural network simple architecture. But I keep getting NAN in result, cant figure out why, below is my code. ...
-1 votes
0 answers
7 views

I want to send parallel inputs to LSTM layers each LSTM layer should recieve 60 timesteps of single feature. How should i shape my inputs

...
0 votes
1 answer
85 views

When one model is superior in real world use?

I have an NLP neural network that I have developed with Keras for multi-label classification. I have fit the model several times and save the best results (via best validation accuracy score) after ...
1 vote
1 answer
338 views

More weightage to a categorical feature for an Autoencoder model

I am using autoencoder for anomaly detection. I don't have any labels already and so its unsupervised. If I have categorical variables, I usually one hot encode before giving it to the model. I would ...
0 votes
1 answer
2k views

Incompatible shapes (None, 1) and (None, 5) with Keras VGGFace Finetuning

Categories to learn and predict: df.race.unique() array(['0', '1', '3', '2', '4'], dtype=object) Data: ...
0 votes
1 answer
2k views

find the number of classes in Cifar-10 dataset

I am trying to find the number of classes in Cifar-10 dataset, but it gives me the error below: ...
0 votes
1 answer
661 views

Retraining EfficientNet on only 2 classes out of 4

EfficientNet model was trained on ~3500 images for a 4-class classification: A, B, C and Neither – with accuracy of 0.985 – by someone else, not me. I'm quite new to ML. So we have this model, and it ...
2 votes
1 answer
3k views

how to use multiple generator in keras fit_generator()

I want to train the multi-input model on a set of images. I use ImageDataGenerator.flow_from_directory() and fit_generator in ...
0 votes
2 answers
61 views

Classification task on boolean only features: what model/layers/activators are better?

I'm trying to build a classification model. Features are purely boolean (not binary) and are in a csv file like 1,0,1,.. The result is an ...

1
2 3 4 5
55