Questions tagged [keras-layer]

The tag has no usage guidance.

0
votes
0answers
9 views

how to get the real shape of batch_size which is none in keras

When implementing a custom layer in Keras, I need to know the real size of batch_size. my shape is (?,20). questions: 1. What is the best way to change (?,20) to (batch_size,20). I have looked into ...
-1
votes
2answers
30 views

Accuracy for Regression

I am experementing molecular activity prediction as regression model in keras. x_train.size=6252312 x_train.shape=(1452, 4306) y_train.shape=(1452, 1) y_train.size=1452 model = Sequential() model....
-3
votes
0answers
17 views

Need a description of theose instructions and the graph created by this code

Donnez une description des instructions ainsi que le graphe crée par ce code : from keras.models import Sequential from keras.layers import Convolution2D from keras.layers import MaxPooling2D from ...
0
votes
1answer
21 views

how to see tensor value of a layer output in keras

I have a Seq2Seq model. I am interested to print out the matrix value of the output of the encoder per iteration. So for example as the dimension of the matrix in the encoder is (?,20) and the epoch =...
0
votes
1answer
15 views

Keras graph disconnected - but why?

Via Keras I create a functional API model based on VGG16 and some custom layers: input_layer = layers.Input(shape=(150, 150, 3), name="model_input") conv_base = VGG16(weights="imagenet", include_top=...
0
votes
0answers
27 views

How to use metric with three inputs(GAP metric) in Keras while training?

This is GAP metric code from kaggle def GAP(pred, conf, true): x = pd.DataFrame({'pred': pred, 'conf': conf, 'true': true}) x.sort_values('conf', ascending=False, inplace=True, na_position='...
0
votes
0answers
17 views

Is there a way to import a pretrained Keras embedding layer into Gensim word2vec?

I've trained a CNN model for sentence classification in Keras and now I want to load the trained embedding layer (input_dim=20000, output_dim=50, input_length=400) into a gensim word2vec model. I know ...
0
votes
1answer
30 views

Keras Model for Molecular Activity

I am experimenting with the Merku molecular activity challenge and I have created the train and test dataset. The shape of the data is the following: x_train.shape=(1452, 4306) y_train.shape=(1452, ...
0
votes
0answers
24 views

CNN with Tf-Idf matrix as input, but without an embedding layer?

I'm trying to work on the airline tweets datasets, and I've explored several possibilities for that. I saw some other tutorials where people used a count matrix (from sklearn CountVectorizer) and then ...
0
votes
1answer
19 views

Converting Keras to Tensorflow — Pruning + Probability

I have a code that mixes Tensorflow Probability (requires TF 2.00) with Keras Pruning, pruning weights of a first Dense Layer and providing inputs for TF probability, having both codes (Keras + TF) in ...
0
votes
0answers
20 views

keras multi-input model: Expected to see 2 array(s), but instead got the following list of 1 arrays

I'm training a functional keras model on mnist dataset. There's a layer that requires 2 inputs - the traditional input tensor and a current batch of on-hot encoded labels. I think I've set up my model ...
0
votes
0answers
7 views

How to make custom gaussian noise layer that imposing different stddev to each column of dataset in Keras?

I want to make gaussian noise layer of Keras that is imposing noise with different stddev level to each column of dataset. However, since I am not know much about coding stuffs, there is a big problem ...
0
votes
1answer
12 views

Fine-tune InceptionV3 model not working as expected

Trying to use transfer learning (fine tuning) with InceptionV3, removing the last layer, keeping training for all the layers off, and adding a single dense layer. When I look at the summary again, I ...
0
votes
2answers
19 views

Why does the last fully-connected/dense layer in a keras neural network expect to have 2 dim even if its input has more dimensions?

I'm trying neural networks with keras for the firs time, and am a bit confused with the dimensions it expects. I am sure that my X_train and y_train data are of the same dimension, and that the X_test ...
0
votes
1answer
25 views

How to create Keras Model() from VGG layers

I have created a custom Keras model using the VGG16 base, which I train and save: from keras.applications import VGG16 from keras import models from keras import layers conv_base = VGG16(weights="...
1
vote
1answer
27 views

What does super achieve

This is the code for building custom keras layer class MyLayer(Layer): def __init__(self, output_dim, **kwargs): self.output_dim = output_dim super(MyLayer, self).__init__(**...
1
vote
2answers
38 views

Get (input) layer of Keras model after saving and re-loading it from disk

I have loaded, extended, trained a VGG16 network via Keras, then saved it to disk: from keras.applications import VGG16 from keras import models conv_base = VGG16(weights="imagenet", include_top=...
1
vote
1answer
65 views

How to split a Keras model, with a non-sequential architecture like ResNet, into sub-models?

My model is a resnet-152 i wanna cutting it into two submodels and the problem is with the second one i can't figure out how to build a model from an intermediate layer to the output I tried this ...
0
votes
1answer
21 views

How to loop through 2D matrices of a 4D (None, x, y, z) activation tensor from a resnet layer?

I wanna loop through 2D matrices of a 4D tensor which is the output of a resnet layer (activation map or feature map) in order to modify it a bit at test time NB: am using keras I tried converting ...
0
votes
0answers
14 views

How can I fix “Unknown layer: DenseFeatures” while importing pre-trained keras model?

I was following the tutorial for classifying structured data from here. I trained the model as described with my data which only comprised of numeric data. I have trained and optimised my model on ...
0
votes
0answers
13 views

keras sub layer function with training weight

I have a custom layer with a function in this. function has a w training weight. How can I working with this in below code. class ConvCaps(tf.keras.layers.Layer): """This constructs a convolution ...
0
votes
0answers
14 views

Autoencoder accuracy not improving using keras

I am trying to create a convolutional autoencoder with keras for expression classification but the accuracy gets stuck after 2-3 epochs at 0.10 (10% max) during training. Is this because of problem in ...
-1
votes
0answers
29 views

Can't add custom layers to topless VGG

I am implementing an algorithm called "IMPROVED BILINEAR POOLING". It consists of taking a VGG or without the FC layers. On top of that, I have added 4 custom layers: the 1st performs the outer ...
-2
votes
0answers
22 views

Why Keras cannot achieve intermediate layers' model and outputs from the trained model directly

This is a question about the API design of Keras. For a trained DNN model defined in Keras, if I want to achieve the intermediate models and outputs of its layers, I have to create a new model. from ...
0
votes
1answer
24 views

AttributeError: 'NoneType' object has no attribute '_inbound_nodes' in Keras

I want to define my own Lstm model as follows: from keras import backend as K from keras.callbacks import ModelCheckpoint from keras.layers.core import Dense, Activation, Flatten, Dropout from keras....
0
votes
0answers
23 views

How to get word embedding of input sequence of words to embedding layer in keras

I wanted to know If the code I have below correctly gives me the word embeddings of the input. model = Sequential() model.add(Embedding(20, 10, input_length = 15, name ="Embedding1")) ...
0
votes
2answers
23 views

Linear activation layer vs no activation layer

I'm playing with Keras a little bit and I'm thinking about what is the difference between linear activation layer and no activation layer at all? Doesn't it have the same behavior? If so, what's the ...
0
votes
1answer
12 views

Inconsistency in Keras Flatten() layer behavior using Theano Backend

I am trying to understand the behavior of the Flatten() layer in Keras with Theano backend. I have two different versions of Keras installed in two different Conda environments. The way a 4D tensor is ...
1
vote
1answer
44 views

How to perform Virtual Batch Normalization (VBN) in keras

VBN is talked in This paper. And implemented Here, Here and Here. I donot want to go to core/full code. I just want to know, how to use VBN as keras layer, as i am not very expert tensorflow/keras ...
0
votes
1answer
24 views

Keras - How to get GRU cell state?

For LSTM we can retrieve last output and last cell state as below outputs, state_h, state_c= LSTM(lstm_dim, return_sequences=True, return_state=True)(inputs) where state_h is the last sequence of ...
0
votes
0answers
52 views

Elmo Embedding Layer by using Keras Layer

from keras.layers import Dense, Input, RepeatVector, Lambda, Permute, Multiply, Concatenate from keras.engine import Layer from keras.layers.convolutional import Conv1D from keras.models import Model ...
0
votes
1answer
27 views

Keras Function (K.function) not working with RNN (code provided)

I was trying to see the each of the layers' outputs on Keras, but I couldn't get to the correct code so I made a simple code where I was stuck at. Question: How am I supposed to get the output of ...
0
votes
1answer
32 views

Splitting a Keras model on an arbitrary layer

I'm trying to create a function that splits a Keras model on a user specified layer. I have the following code: def return_split_models(model, layer): model_f, model_h = Sequential(), Sequential()...
1
vote
1answer
38 views

How to use Keras LSTM batch_input_size properly

I'm using Keras framework to build a stacked LSTM model as follows: model.add(layers.LSTM(units=32, batch_input_shape=(1, 100, 64), stateful=True, ...
0
votes
2answers
46 views

How to write a keras lambda layer to turn a 'vector' input layer into a 'image' layer with keras backend?

I have two inputs to the model: input_img = Input(shape=(self.img_rows, self.img_cols, self.channels,)) input_cond = Input(shape=(self.cond_dim,)) Their shapes are different, I want to expand each ...
1
vote
1answer
50 views

trainable_variables attribute of the custom layer in Keras returns empty list

I tried to build my own custom layer in tensorflow/keras that enforces the layer to be symmetric and what I ended up with is the following: import tensorflow as tf from tensorflow.python.framework....
0
votes
0answers
24 views

How to use the dot merge in keras 2.0?

I am building a recommender system using deep learning. When defining my model I get the following error: ValueError: Layer dot_1 was called with an input that isn't a symbolic tensor. Received ...
0
votes
1answer
28 views

how do I feed the inputs of network if it has not fed by model.fit?

I have a simple network in keras and I define a custom layer which does some operations on input tensor and then returns it to the network, but when I want to implement it, it produces the following ...
1
vote
1answer
36 views

Where do the parameters in keras layers apply?

I'm trying to get to grips with the basics of neural networks and am struggling to understand keras layers. Take the following code from tensorflow's tutorials: model = keras.Sequential([ keras....
0
votes
0answers
14 views

How to define a morphology operation in a Neural Network as an activation function?

I recently completed a task to study how to use morphological operation as an activation function for neural networks. But I had no idea and didn't know how to use keras for custom functionality. Can ...
0
votes
0answers
9 views

ValueError: Error when checking target: expected dense_1 to have 4 dimensions, but got array with shape (5, 1)

train_datagen = ImageDataGenerator(rescale=1./255) test_datagen = ImageDataGenerator(rescale=1./255) train_generator = train_datagen.flow_from_directory( 'dataset/train', target_size=...
1
vote
1answer
38 views

How to create a custom keras layer “min pooling” but ignore zeros?

I am working on neural networks with keras and tensorflow backend. Usually it is built up with convolutional and max pooling layers like it's done in vgg16 for example. For my neural network I would ...
0
votes
0answers
28 views

Error when checking target: expected dense_13 to have shape (39,) but got array with shape (1,)

I am working on model in Keras, on a 3 classes subset , and encountered the following error: TypeError: __init__() missing 1 required positional argument: 'units' I read multiple similar issues ...
0
votes
1answer
13 views

Expand Model layer

I have a pretained model with summary: Layer (type) Output Shape Param # ================================================================= vgg19 (Model) ...
0
votes
0answers
36 views

How to explain get_weight with autoencoder in keras?

I built an autoencoder model of three layers with 9 5 9. Input dim =9, encoder dim =5, output dim=9 When I get the model weights, weight1=autoencoder.layers[1].get_weights() weight2=autoencoder....
1
vote
1answer
37 views

Keras 2: Using lambda function in “Merge” layers

I am trying to implement this merge layer: policy = merge([out1, out2], mode = lambda x: x[0]-K.mean(x[0])+x[1], output_shape = (out_node,)) However, "merge" is no longer present in Keras 2. You can ...
-1
votes
0answers
28 views

Loss is not reducing while training a binary classifier

Am trying to build the binary classifier model, which helps to predict the given number is even/dd. Created 50k samples to train the modal, after three epochs the loss rate is not reducing below 0.6. ...
3
votes
1answer
37 views

Dynamic Activation Function in Keras

I'm working on a research project which involves replacing certain ReLu activations with polynomial activations. The code I inherited is using Keras with TensorFlow backend - something I have little ...
1
vote
0answers
159 views

Keras - The added layer must be an instance of class Layer. Found: Tensor

I'm trying to implement skip-gram using keras. Getting error while adding the Dot() layer. The below implementation is inspired by Dipanjan code. I have done some modification related to different ...
0
votes
0answers
13 views

Keras, try to backprop from the layer step + 1 of the output layer

While I was trying to reimplement keras seq2seq as from the official website. https://keras.io/examples/lstm_seq2seq/ Cause: The problem is that some of the languages contain too many characters so ...

http://mssss.yulina-kosm.ru