Questions tagged [keras]

Keras is a neural network library providing a high-level API in Python and R. Use this tag for questions relating to how to use this API. Please also include the tag for the language/backend ([python], [r], [tensorflow], [theano], [cntk]) that you are using. If you are using tensorflow's built-in keras, use the [tf.keras] tag.

Keras is a high-level deep learning API, written in , similar in spirit to and . It is developed with a focus on enabling fast experimentation and now solely uses as backend. Additionally, it also has a interface.

Having a simple API with less capabilities, Keras is often seen as a good place to start experimenting with deep learning. For beginners, the Sequential API is easy to learn. For intermediate users, the Functional API has more capabilities and flexibility, but it comes at the cost of simplicity. For expert users, the Subclassing API enable ultimate capabilities, that should only be used in experimental settings.

Starting from TensorFlow 1.8 versions, Keras is also integrated in the TensorFlow framework. The creator of Keras, Francois Chollet, recommends that Keras should to be used from inside TensorFlow, as of TensorFlow version 2.0, since the latter package is much better maintained and will be updated in the future/less prone to errors as compared to the plain Keras library.

References:

42247 questions
9
votes
0 answers

Keras Neural Nets, How to remove NaN values in output?

I keep getting a few NaN outputs from my neural network using Keras. I only get about one NaN per 10,000 results. Originally I had a relu activation layer feeding into the final softmax layer. This produced more NaN results. I changed the…
chasep255
  • 11,745
  • 8
  • 58
  • 115
9
votes
1 answer

Python keras how to transform a dense layer into a convolutional layer

I have a problem finding the correct mapping of the weights in order to transform a dense layer into a convolutional layer. This is an excerpt of a ConvNet that I'm working on: model.add(Convolution2D(512, 3, 3,…
pkropf
  • 93
  • 1
  • 4
9
votes
1 answer

How to control memory while using Keras with tensorflow backend?

I have created a wrapper class which initializes a keras.models.Sequential model and has a couple of methods for starting the training process and monitoring the progress. I instantiate this class in my main file and perform the training process.…
Chintak
  • 365
  • 4
  • 14
9
votes
2 answers

How to use the Embedding Layer for Recurrent Neural Network (RNN) in Keras

I'm rather new to Neural Networks and the Keras Library and I'm wondering how I can use the Embedding Layer as described here to mask my input data from a 2D tensor to a 3D tensor for a RNN. Say my timeseries data looking as follows (with an…
Kito
  • 1,375
  • 4
  • 17
  • 37
8
votes
1 answer

Tensorflow: The channel dimension of the inputs should be defined

I am new to Tensorflow, and am trying to train a specific deep learning neural network. I am using Tensorflow (2.11.0) to get a deep neural network model which is described below. The data which I use is also given below: Data: Here is some example…
Ling Guo
  • 592
  • 4
  • 12
8
votes
2 answers

How to split folders to 3 datasets with ImageDataGenerator?

validation_split parameter is able to allow ImageDataGenerator to split the data sets reading from the folder into 2 different disjoint sets. Is there any way to create 3 sets - of training, validation, and evaluation datasets using it? I am…
zs2020
  • 53,766
  • 29
  • 154
  • 219
8
votes
1 answer

ModuleNotFoundError: No module named 'keras.applications.resnet50 on google colab

I am trying to run an image-based project on colab. I found the project on github. Everything runs fine till I reached the cell with the following code: import keras from keras.preprocessing.image import ImageDataGenerator from…
8
votes
1 answer

Can SigmoidFocalCrossEntropy in Tensorflow (tf-addons) be used in Multiclass Classification? ( What is the right way)?

Focal Loss given in Tensorflow is used for class imbalance. For Binary class classification, there are a lots of codes available but for Multiclass classification, a very little help is there. I ran the code with One Hot Encoded target variables of…
Deshwal
  • 3,436
  • 4
  • 35
  • 94
8
votes
5 answers

How to fix error: Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers

When I am trying to run a Python code for deep learning utilizing the TensorFlow library, I am getting the following error: 2021-10-24 10:07:13.619481: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library…
GEOFFREY ZIMBA
  • 101
  • 1
  • 1
  • 2
8
votes
6 answers

Problem with inputs when building a model with TFBertModel and AutoTokenizer from HuggingFace's transformers

I'm trying to build the model illustrated in this picture: I obtained a pre-trained BERT and respective tokenizer from HuggingFace's transformers in the following way: from transformers import AutoTokenizer, TFBertModel model_name =…
8
votes
1 answer

MultiHeadAttention attention_mask [Keras, Tensorflow] example

I am struggling to mask my input for the MultiHeadAttention Layer. I am using the Transformer Block from Keras documentation with self-attention. I could not find any example code online so far and would appreciate if someone could give me a code…
8
votes
4 answers

AttributeError: module 'keras.utils' has no attribute 'get_file' using segmentation_models

I'm trying to use segmentation models but I can't fix this error. I've searched for this particular one but couldn't find an answer. I'm using pycharm and this error is linked to this specific line of code BACKBONE = 'resnet34' model1 =…
giulia
  • 81
  • 1
  • 1
  • 2
8
votes
0 answers

TensorFlow Keras: The `validate_indices` argument has no effect. Indices are always validated on CPU and never validated on GPU

It was yesterday and I was training the model. Everything looked good. Today 27/05/2021 I receive this warning: WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/array_ops.py:5049: calling gather (from…
8
votes
2 answers

Implementing Binary Cross Entropy loss gives different answer than Tensorflow's

I am implementing the Binary Cross-Entropy loss function with Raw python but it gives me a very different answer than Tensorflow. This is the answer I got from Tensorflow:- import numpy as np from tensorflow.keras.losses import…
user12188405
8
votes
3 answers

Cannot use keras models on Mac M1 with BigSur

I am trying to use Sequential model from keras of tensorflow. When I am executing following statement: model.fit(x_train, y_train, epochs=20, verbose=True, validation_data=(x_dev, y_dev), batch_size=10) I am getting following errors: I…
Ankita
  • 159
  • 1
  • 3
  • 10
1 2 3
99
100