Questions tagged [keras]

Open source high-level neural network library for Python and R. Is capable of using TensorFlow or Theano as backend.

667 questions
270
votes
6 answers

What is batch size in neural network?

I'm using Python Keras package for neural network. This is the link. Is batch_size equals to number of test samples? From Wikipedia we have this information: However, in other cases, evaluating the sum-gradient may require expensive evaluations…
user2991243
  • 3,621
  • 4
  • 22
  • 48
173
votes
3 answers

How does Keras 'Embedding' layer work?

Need to understand the working of 'Embedding' layer in Keras library. I execute the following code in Python import numpy as np from keras.models import Sequential from keras.layers import Embedding model = Sequential() model.add(Embedding(5, 2,…
prashanth
  • 3,747
  • 4
  • 21
  • 33
113
votes
6 answers

What loss function for multi-class, multi-label classification tasks in neural networks?

I'm training a neural network to classify a set of objects into n-classes. Each object can belong to multiple classes at the same time (multi-class, multi-label). I read that for multi-class problems it is generally recommended to use softmax and…
aKzenT
  • 1,231
  • 2
  • 8
  • 5
43
votes
4 answers

Is it possible to give variable sized images as input to a convolutional neural network?

Can we give images with variable size as input to a convolutional neural network for object detection? If possible, how can we do that? But if we try to crop the image, we will be loosing some portion of the image and if we try to resize, then, the…
38
votes
3 answers

Understanding input_shape parameter in LSTM with Keras

I'm trying to use the example described in the Keras documentation named "Stacked LSTM for sequence classification" (see code below) and can't figure out the input_shape parameter in the context of my data. I have as input a matrix of sequences of…
mazieres
  • 597
  • 1
  • 5
  • 9
30
votes
5 answers

What is the difference between Conv1D and Conv2D?

I was going through the keras convolution docs and I have found two types of convultuion Conv1D and Conv2D. I did some web search and this is what I understands about Conv1D and Conv2D; Conv1D is used for sequences and Conv2D uses for images. I…
Eka
  • 1,921
  • 2
  • 22
  • 28
25
votes
3 answers

What is the difference between kernel, bias, and activity regulizers, and when to use which?

I've read this post, but I wanted more clarification for a broader question. In Keras, there are now three types of regularizers for a layer: kernel_regularizer, bias_regularizer, activity_regularizer. I have read posts that explain the difference…
Christian
  • 1,382
  • 3
  • 16
  • 27
25
votes
6 answers

How do I make my neural network better at predicting sine waves?

Here, have a look: You can see exactly where the training data ends. Training data goes from $-1$ to $1$. I used Keras and a 1-100-100-2 dense network with tanh activation. I calculate the result from two values, p and q as p / q. This way I can…
Markus Appel
  • 361
  • 1
  • 3
  • 5
22
votes
2 answers

How the embedding layer is trained in Keras Embedding layer

How is the embedding layer trained in Keras Embedding layer? (say using tensorflow backend, meaning is it similar to word2vec, glove or fasttext) Assume we do not use a pretrained embedding.
william007
  • 897
  • 1
  • 6
  • 9
20
votes
1 answer

Why can't a single ReLU learn a ReLU?

As a follow-up to My neural network can't even learn Euclidean distance I simplified even more and tried to train a single ReLU (with random weight) to a single ReLU. This is the simplest network there is, and yet half the time it fails to…
endolith
  • 533
  • 4
  • 17
18
votes
3 answers

Why does the loss/accuracy fluctuate during the training? (Keras, LSTM)

I use LSTM network in Keras. During the training, the loss fluctuates a lot, and I do not understand why that would happen. Here is the NN I was using initially: And here are the loss&accuracy during the training: (Note that the accuracy actually…
Valeria
  • 511
  • 1
  • 3
  • 11
16
votes
2 answers

When to "add" layers and when to "concatenate" in neural networks?

I am using "add" and "concatenate" as it is defined in keras. Basically, from my understanding, add will sum the inputs (which are the layers, in essence tensors). So if the first layer had a particular weight as 0.4 and another layer with the same…
Christian
  • 1,382
  • 3
  • 16
  • 27
15
votes
2 answers

Is there a way to incorporate new data into an already trained neural network without retraining on all my data in Keras?

I have already trained a neural network on my data. In the future, I will receive some more data. How can I incorporate this data into my model without rebuilding it from scratch?
yalpsid eman
  • 273
  • 1
  • 2
  • 10
15
votes
2 answers

How to set mini-batch size in SGD in keras

I am new to Keras and need your help. I am training a neural net in Keras and my loss function is Squared Difference b/w net's output and target value. I want to optimize this using Gradient Descent. After going through some links on the net, I have…
14
votes
3 answers

How would I bias my binary classifier to prefer false positive errors over false negatives?

I've put together a binary classifier using Keras' Sequential model. Of its errors, it predicts with false negatives more frequently than false positives. This tool is for medical application, where I'd prefer a false positive as to err on the side…
PhlipPhlops
  • 143
  • 5
1
2 3
44 45