Questions tagged [keras]

1

votes
1

answer
311

Views

Why return sequences in stacked RNNs?

When stacking RNNs, it is mandatory to set return_sequences parameter as True in Keras. For instance in Keras, lstm1 = LSTM(1, return_sequences=True)(inputs1) lstm2 = LSTM(1)(lstm1) It is somewhat intuitive to preserve the dimensionality of input space for each stacked RNN layer, however, I am not...
Buomsoo Kim
0

votes
0

answer
3

Views

how to use eager execution to save and restore in TensorFlow?

We always use tf.train.Saver() to save and restore weights, like the following example(https://www.tensorflow.org/guide/saved_model). But how to use eager execution to save? how to change the following example? Another question, is it a good idea to use eager? I fond tf.contrib.eager.Saver in (ht...
andy
1

votes
1

answer
525

Views

Trading in precision for better recall in Keras classification neural net

There's always a tradeoff between precision and recall. I'm dealing with a multi-class problem, where for some classes I have perfect precision but really low recall. Since for my problem false positives are less of an issue than missing true positives, I want reduce precision in favor of increasin...
megashigger
1

votes
2

answer
852

Views

How to interpret MSE in Keras Regressor

I am new to Keras/TF/Deep Learning and I am trying to build a model to predict house prices. I have some features X (no. of bathrooms , etc.) and target Y (ranging around $300,000 to $800,000) I have used sklearn's Standard Scaler to standardize Y before fitting it to the model. Here is my Keras mod...
Ivan
1

votes
5

answer
1.2k

Views

Python add one more channel to image

I'm trying to add channel because of below error ValueError: could not broadcast input array from shape (48,48) into shape (48,48,1) Code: img = cv2.imread(f,0) resized = cv2.resize(img, (48,48), interpolation = cv2.INTER_AREA) print(resized.shape) (48, 48) But I need a channel image like (48,48,1...
Hasan Ramazan
0

votes
0

answer
4

Views

[Keras][Embedding] How do I expand the vocabulary size of a pre trained embedding

I have a pre-trained Keras model and there's a word embedding [1000 vocabulary * 200 dimensions] inside of the model. Now I want to load it back to memory and continuous training it with new data. The vocabulary size increased because of the new data. I am wondering if it's possible to replace this...
Weiye Deng
1

votes
4

answer
10.5k

Views

How do I upgrade “keras” from 1.2.0 to 2.0.0?

I am running an image classifier but it keeps producing the error Keras loaded from keras Python module v1.2.0, however version 2.0.0 is required. Please update the keras Python package. Error in py_call_impl(callable, dots$args, dots$keywords) : TypeError: init() got an unexpected keyword argumen...
KaRJ XEN
1

votes
1

answer
1.8k

Views

What is the difference between “predict” and “predict_class” functions in keras?

What is the difference between predict and predict_class functions in keras? Why does Model object don't have predict_class function?
hyqdvd
1

votes
2

answer
3.7k

Views

module 'tensorflow.python.keras.datasets.fashion_mnist' has no attribute 'load_data'

I am currently following this intro tutorial on the Keras website: https://www.tensorflow.org/tutorials/keras/basic_classification Several steps in I run into this error after calling fashion_mnist.load_data(): AttributeError: module 'tensorflow.python.keras.datasets.fashion_mnist' has no attribute...
Brendan Gregory
1

votes
1

answer
761

Views

Can I add Tensorflow Fake Quantization in a Keras sequential model?

I have searched this for a while, but it seems Keras only has quantization feature after the model is trained. I wish to add Tensorflow fake quantization to my Keras sequential model. According to Tensorflow's doc, I need these two functions to do fake quantization: tf.contrib.quantize.create_traini...
17_Python
1

votes
1

answer
293

Views

KERAS “sparse_categorical_crossentropy” question

As an input a have a float 1.0 or 0.0. When I try to predict with my model and the sparse_categorical_crossentropy loss I get something like: [[0.4846592 0.5153408]]. How do I know what category it predicts?
user9468014
1

votes
1

answer
587

Views

Stop Training in Keras when Accuracy is already 1.0

How will I stop Keras Training when the accuracy already reached 1.0? I tried monitoring loss value, but I haven't tried stopping the training when the accuracy is already 1. I tried the code below with no luck: stopping_criterions =[ EarlyStopping(monitor='loss', min_delta=0, patience = 1000), Earl...
Eliyah
1

votes
1

answer
305

Views

Keras Embedding ,where is the “weights” argument?

I have seen such kind of code as follow: embed_word = Embedding(params['word_voc_size'], params['embed_dim'], weights=[word_embed_matrix], input_length = params['word_max_size'] , trainable=False, mask_zero=True) When I look up the document in Keras website [https://faroit.github.io/keras-docs/2.1.5...
Johnny
0

votes
0

answer
5

Views

How to use RNN cell in a network?

I am trying to use a customized RNN cell in my network. I started with the RNN cell example of Keras where the RNN cell is defined as MinimalRNNCell. When I am trying to use the defined cell in my recurrent network, by replacing a simpleRNN that I was using previously with the customized RNN cell, b...
omid
0

votes
0

answer
2

Views

Does normalizing images by dividing by 255 leak information between train and test set?

I've seen division by 255 used many times as normalization in CNN tutorials online, and this is done across the entire dataset before train test split. I was under the impression that the test set should be normalized according to the mean/std/maxmin etc. of the training set. By using /255 across th...
SCool
1

votes
2

answer
204

Views

“ ImportError: DLL load failed: The specified procedure could not be found”- while Digit Recognition using CNN in Python using Keras

I am trying to write a simple character recolonization code using convolutional neural network in python on windows. I am following this tutorial. But somehow I am having following error message. I could not find the appropriate reason of this error. It would be helpful for me if anyone can breakdow...
Mahin
1

votes
1

answer
87

Views

How do Convolutional Layers (CNNs) work in keras?

I notice that in the keras documentation there are many different types of Conv layers, i.e. Conv1D, Conv2D, Conv3D. All of them have parameters like filters, kernel_size, strides, and padding, which aren't present in other keras layers. I have seen images like this which 'visualize' Conv layers, b...
Primusa
1

votes
1

answer
184

Views

ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (6243, 256, 256)

I want to append the label on the training dataset and I do it as def one_hot_label(img): label = img if label == 'A': ohl = np.array([1, 0]) elif label == 'B': ohl = np.array([0, 1]) return ohl def train_data_with_label(): train_images = [] for i in tqdm(os.listdir(train_data)): path_pre = os.path....
AKF
1

votes
3

answer
62

Views

Difference btwn high and low level libraries

What is the difference btwn high level and low level libraries? I understand that keras is a high level library and tensorflow is a low level library but I'm still not familiar enough with these frameworks to understand what that means for high vs low libraries.
maddie
1

votes
1

answer
32

Views

How to use tensorflow2.0 dataset with keras ImageDataGenerator

i am using tensorflow 2.0 API where i created a dataset from all image paths like example below X_train, X_test, y_train, y_test = train_test_split(all_image_paths, all_image_labels, test_size=0.20, random_state=32) path_train_ds = tf.data.Dataset.from_tensor_slices(X_train) image_train_ds = path_t...
kero
1

votes
1

answer
17

Views

Missing val_acc after fitting sequential model

I am missing information about the 'val_acc' attribute when I fit a compiled sequential model. I have a sequential model that is compiled with 'accuracy' metrics model = Sequential() model.add(Dense(12, input_dim=8, activation='relu')) model.add(Dense(8, activation='relu')) model.add(Dense(1, activ...
pobu
1

votes
1

answer
45

Views

Why are the prediction probabilities so high for images with no defined class?

I have been stuck here for too long now. I am trying to create a CNN that could detect the numbers in an image. For this I started working with The Street View House Numbers (SVHN) Dataset. This dataset comes with pre-processed images scaled to 32x32 digits.There are 10 classes for 10 numbers. I t...
Amanda
0

votes
0

answer
2

Views

What's the difference between these 2 Keras approaches in Transfer Learning?

I've seen two different approaches for Transfer Learning/Fine Tuning and I'm not sure about their differences and benefits: One simply loads the model, eg. Inception, initialized with the weights generated from training on eg. Imagenet, freezes the conv layers and appends some dense layers to adapt...
crash
1

votes
1

answer
22

Views

How do I fix the dimension of the return value of flow from Image Generator?

I am trying to use fit_generator. But I get the error Error when checking input: expected sequential_1_input to have 3 dimensions, but got array with shape (20, 28, 28, 1) Here is the code: data_flow = data_generator.flow(x_train, y_train,batch_size=20) generate = model.fit_generator(data_flow, st...
Kiran Shrestha
1

votes
0

answer
7

Views

Detailed examples of what Keras cannot do but Pytorch can?

I read many articles saying Keras is too high level and hard to be used for research. I found Keras has Lambda layer, and custom layer, so what are some detailed examples of what Pytorch can achieve while Keras cannot or is very tricky to? Thanks.
Herbert
0

votes
0

answer
11

Views

What does Keras model.predict returns?

I am building an autoencoder network for finding outliers in a single-column list of text. I pick up each character, transform it to ASCII, and put them into an array. Each line of the array is a row of my input, and each element in the array is an integer representation of the ascii code for the ch...
gtbono
0

votes
0

answer
22

Views

Design neural network to find inputs with highest probability of class

I am designing a neural network for classification with the aim to find the inputs with the highest probability that they belong to one of two classes. There are two classes, class A and class B. I have a set of data of which I want to find the inputs that have the highest probability that they belo...
ig-dev
0

votes
0

answer
6

Views

How to have multiple predictions in Keras?

A model I am training has two separate FFNNs for an inputted query and document. The loss function is a similarity between the outputs of these two FFNNs. I would then like to use these separate FFNNs to encode a bunch of queries and a bunch of documents, separately. Does Keras have a way to have...
SantoshGupta7
1

votes
0

answer
9

Views

Batch Normalization results inconsistent across Keras and Tensorflow for toy example: why?

I'm trying to get BatchNormalization working properly in Keras (2.2.4), and haven't had luck. Its behavior seems inconsistent across model.fit() and model.predict()/evaluate(). My original problem was in the context of a complex GAN setup with various layers that were switching between frozen and u...
user1519525
-1

votes
0

answer
10

Views

Multiple Softmax in Dense Layer [KERAS]

I have a network, I want to apply softmax on dense layer like i have dense layer of shape (?, 312), I want to apply softmax on dense layer on units 1-9, 10-18...etc. I donot know how to do that. I mentioned an image below, i want something like this. I tried something like this but this doesnpt se...
Muneeb ul Hassan
0

votes
0

answer
5

Views

Issues splitting autoencoder model in Keras

I have trained an autoencoder and saved it using keras built in save() method. Now I want to split it into two parts: Encoder and decoder. I can successfully load the model and get the encoder part by creating a new model using the old model: encoder_model = keras.models.Model(inputs=self.model.inpu...
Matas Minelga
0

votes
0

answer
14

Views

Use neural network to learn distribution of values for classification

Use neural network to learn distribution of values for classification The aim is to classify 1-D inputs using a neural network. There are two classes that should be classified, A and B. Each input, used to determine the class, is a number between 0.0 and 1.0. The input values for class A are evenly...
ig-dev
0

votes
0

answer
4

Views

Why is the model not learning with pretrained vgg16 in keras?

I am using the pre-trained VGG 16 model available with Keras and applying it on the SVHN dataset which is a dataset of 10 classes of number 0 - 10. The network is not learning and has been stuck at 0.17 accuracy. There is something that I am doing incorrectly but I am unable to recognise it. The way...
Amanda
0

votes
1

answer
20

Views

I need to make decomposition of vector

There is a Python vector of N numbers. It is necessary to group these numbers into one-dimensional arrays so that the number of arrays is minimal. While the sum of the elements of each array was also the minimum possible. It is input vector stuff = [1, 2, 3, 4, 5, 6] I`d like to output arrays: [1, 6...
-2

votes
0

answer
19

Views

How many number of neurons are in the first input layer model.add(Conv2D(64, kernel_size=(3, 3),input_shape=(200,200,3))

1)how many number of neurons in the input layer? I'm giving the input size of image as 200*200 2)I guess the number of neurons for input layer should be number of (features) pixels of an input image (in this case 200*200) 3)what if there are more number of neurons in the input layer than the feature...
Rohan Dhere
-1

votes
0

answer
18

Views

CNN model converges with small, grayscale dataset [DVMM] but not with a large, colour dataset [CASIA]

I created a CNN model, in which the first layer is initialized by 30 high pass filters (which act like edge detectors), to detect tampering in images. The model accepts input patches of size 128x128. It trains well on a grayscale dataset - DVMM Columbia dataset - and gives accuracy upto 90%. An exam...
Abdul Muizz
1

votes
1

answer
4.9k

Views

NameError when opening Keras model that uses Tensorflow Backend

I wanted to resize my input image in my first Keras layer so I followed this SO question. Solution worked great until I saved my model, and then tried to use it in another file and it throws NameError: name 'ktf' is not defined I tried adding: from keras.backend import tf as ktf to the file opening...
DrTarr
1

votes
3

answer
342

Views

Neural network sine approximation

After spending days failing to use neural network for Q learning, I decided to go back to the basics and do a simple function approximation to see if everything was working correctly and see how some parameters affected the learning process. Here is the code that I came up with from keras.models imp...
user3548298
1

votes
2

answer
498

Views

Embedding in Keras

Which algorithm is used for embedding in Keras built-in function? Word2vec? Glove? Other? https://keras.io/layers/embeddings/
oren_isp
1

votes
2

answer
112

Views

Keras Functional API Multi Input Layer

How do I define a multi input layer using Keras Functional API? Below is an example of the neural network I want to build. There are three input nodes. I want each node to be a 1 dimensional numpy array of different lengths. Here's what I have so far. Basically I want to define an input layer with m...
cooldood3490

View additional questions