Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
660 views

Unrecognized keyword arguments passed to Embedding: {'input_length': 10}

I am trying to build this RNN below, import keras model = Sequential() input_dim=3 output_dim=1 input_length=1 model.add(keras.layers.Embedding(input_dim, output_dim, input_length=input_length)) ...
Arian's user avatar
  • 1
1 vote
0 answers
244 views

Replace embedding layer in Keras model while keeping the rest of the architecture and weights intact

I have created a Keras Sequential Neural Network for sentiment analysis on twitter data, with the help of gensim word2vec library. I am creating an embedding dictionary by training the word2vec model ...
Klara Lundgren's user avatar
2 votes
1 answer
153 views

How to extract embeddings generated from sparknlp WordEmbeddingsModel to feed a RNN model using keras and tensorflow

I have a text classification problem. I'm particularly interested in this embedding model in sparknlp because I have a dataset from Wikipedia in 'sq' language. I need to convert sentences of my ...
Aiha's user avatar
  • 51
3 votes
4 answers
3k views

What does GlobalAveragePooling1D do in keras?

In the embedding example here: https://www.tensorflow.org/text/guide/word_embeddings result = embedding_layer(tf.constant([[0, 1, 2], [3, 4, 5]])) result.shape TensorShape([2, 3, 5]) Then it explains:...
marlon's user avatar
  • 7,555
1 vote
1 answer
62 views

Is Embedding layer output stochastic?

If I use two identical models to learn over a dataset, but the order in which the samples are presented differs, would an embedding layer output the exact embeddings?
HenDoNR's user avatar
  • 93
0 votes
1 answer
235 views

Use of embeddings to preserve order invariance

I want to recommend an item complementary to a cart of items. So, naturally, I thought of using embeddings to represent items, and I came up to a layer of this kind in keras: item_input = Input(shape=(...
Mark Morrisson's user avatar
0 votes
1 answer
180 views

Masking zeroes in LSTM

My data set is satellite observation which includes a lot of zeroes so that highly effect my final simulation results. I have two sets of input data, dynamic ones (X_dynamic_LSTM.shape (95931, 1, 5)) ...
babak asadolah's user avatar
0 votes
1 answer
695 views

Can I feed categorical data in Keras embedding layer without encoding the data?

I am trying to feed multicolumn categorical data into Keras embedding layer. Can I feed categorical data in Keras embedding layer without encoding ? If not then which encoding method is preferable to ...
Abdullah Al Munem's user avatar
1 vote
0 answers
671 views

Embedding layer with one-hot encoding

Let's assume that I have one-hot encoded input data. I will give an example from that stack exchange link Suppose that we have just 2 sentences: Hope to see you soon Nice to see you again Therefore, ...
Angerato's user avatar
  • 155
1 vote
1 answer
859 views

Why in Keras embedding layer's matrix is a size of vocab_size + 1?

I have below toy example where my vocabulary size is 7, embedding size is 8 BUT weights output of Keras Embedding layer is 8x8. (?) How is that? This seems to be connected to other questions related ...
Error Replicator's user avatar
1 vote
2 answers
1k views

Tensorflow's seq2seq: tensorflow.python.framework.errors_impl.InvalidArgumentError

I am following quite closely the Seq2seq for translation tutorial here https://www.tensorflow.org/addons/tutorials/networks_seq2seq_nmt#define_the_optimizer_and_the_loss_function while testing on ...
kiriloff's user avatar
  • 26.3k
0 votes
0 answers
301 views

How embedding layer works when the length of inputs are not fixed for each batch?

I'm reading the book "Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd Edition". In chapter 16 the author explains Sentiment Analysis using imdb reviews. When I was ...
Cristhian Boujon's user avatar
2 votes
1 answer
3k views

ValueError: The last dimension of the inputs to a Dense layer should be defined. Found None

I'm playing around a bit with Tensorflow 2.7.0 and its new TextVectorization layer. However, something does not work quite right in this simple example: import tensorflow as tf import numpy as np X = ...
Garve's user avatar
  • 35
1 vote
1 answer
918 views

connect embedding layer with dimension (3,50) to lstm

how to connect embedding layer with dimension (3,50) to lstm? array (3, 50) is fed to input "layer_i_emb" where three time steps with arrays of length 50 are stored in which product ...
Alihan Urumov's user avatar
1 vote
1 answer
825 views

Keras embedding layer set_weights() error on google colab

I am trying to manually set new weights for the Keras embedding layer of an LSTM model I created on google colab (tf version 2.6.0) using this code: model4Ax.layers[0].set_weights(emb4A) emb4A is the ...
Oluwagbemiga Ajayi's user avatar
1 vote
0 answers
71 views

How to set input shape of LSTM for sentence level embedding

I am working with LSTM with sentence level embedding. I have review text where I set the max length sentence of review=58 and convert the each sentence in the review to embedding with 1024 dimension. ...
aldin's user avatar
  • 23
0 votes
0 answers
211 views

How to use weights of embedding layers as alternative feature for categorical feature

I am working on categorical data that i want to use weight of embedding layers to enhance the quality of information. After training model: the weight of one categorical feature looks like as below: ...
Phạm Tâm's user avatar
1 vote
1 answer
1k views

How to merge multiple input and embeddings into single input layer

I have various inputs, some that need embedding. I have been able to create them all as seen below: I can then concatenate them all, for the following: However, my disconnect is where to go from ...
Stu's user avatar
  • 1,633
2 votes
0 answers
652 views

Trouble when using Categorical Embedder package

Here is my code: import categorical_embedder as ce and the error is: --------------------------------------------------------------------------- ImportError Traceback (...
Phạm Tâm's user avatar
0 votes
1 answer
282 views

How to make an array as a word embedding, similar to tf.keras.datasets.imdb.get_word_index?

Im new to machine learning. I saw a code for binary classification with Movie reviewsd from IMDB. I was trying to use the same code with my own dataset (where the columns are "text": this is ...
GUNTER's user avatar
  • 129
0 votes
0 answers
161 views

Sentiment Analysis with word embeddings using Keras Embedding Layer

I need a little bit of clarification regarding my model results. Here is my use case: Deciding whether a review from a company from S&P 500 is negative or positive. I used a crawled data set from ...
philuix's user avatar
  • 109
1 vote
0 answers
111 views

Python - ValueError: total size of new array must be unchanged

I'm trying to use Entity Encoding with Keras. These are my categorical and numeric features. Dataset is from the Rossmann Store Sales competition on Kaggle. cat_cols = ['Store', 'DayOfWeek', '...
Federico's user avatar
1 vote
1 answer
990 views

Keras multi input one shared embedding layer

Is it possible to simply share one embedding layer with one input with multiple features ? Is it possible to avoid to create multiple inputs layers one by feature. I would like to avoid to create 34 ...
Damien Bouchabou's user avatar
1 vote
1 answer
711 views

Keras Functional API embedding layer output to LSTM

When passing the output of my embedding layer to the LSTM layer I'm running into a ValueError that I cannot figure out. My model is: def lstm_mod(self, n_cells,batch_size): input = tf.keras....
Juan Vainas's user avatar
2 votes
3 answers
2k views

Why Keras Embedding layer's input_dim = vocab_size + 1

In this code snippet from TensorFlow tutorial Basic text classification, model = tf.keras.Sequential([ layers.Embedding(max_features + 1, embedding_dim), layers.Dropout(0.2), layers....
Splash's user avatar
  • 117
0 votes
1 answer
613 views

Pre-trained embedding layer: tf.constant with unsupported shape

I am going to use pre-trained word embeddings in Keras model. my matrix weights are stored in ;matrix.w2v.wv.vectors.npy; and it has shape (150854, 100). Now when I add the embedding layer in the ...
Raz's user avatar
  • 25
0 votes
1 answer
181 views

How do I train deep learning neural network that contains embedding layer using GPU?

I'm getting a InvalidArgumentError on my embedding layer: Colocation Debug Info: Colocation group had the following types and supported devices: Root Member(assigned_device_name_index_=2 ...
Shengy90's user avatar
1 vote
0 answers
530 views

InvalidArgumentError: indices[82,0] = 69687 is not in [0, 69054)

I'm traing a four layer Deep Neural Network but I keep having this error: InvalidArgumentError: indices[82,0] = 69687 is not in [0, 69054) [[Node: user_emb_12/embedding_lookup = Gather[Tindices=...
Cristina's user avatar
0 votes
1 answer
570 views

Bag of Words embedding layer in Keras?

I have a very simple Keras model that looks like: model = Sequential() model.add(Dense(hidden_size, input_dim=n_inputs, activation='relu')) model.add(Dense(n_outputs, activation='softmax')) The ...
priegueee's user avatar
1 vote
1 answer
1k views

Warning when adding Regularization to embedding layer

When I add l2 Regularization to my Embedding for my categorical Data like so: emb_layer = [] cat_dim = len(cat_ix) X = Input(shape=(cat_dim,)) X_split = Lambda(lambda x: tf.split(x, ...
Malte's user avatar
  • 101
1 vote
1 answer
937 views

Dimensions between embedding layer and lstm encoder layer don't match

I am trying to build an encoder-decoder model for text generation. I am using LSTM layers with an embedding layer. I have somehow a problem with the output of the embedding layer to the LSTM encoder ...
Joachim's user avatar
  • 499
3 votes
0 answers
238 views

how to embed N-grams

for improving my model I use to give character based 3- Gram instead of word :) the code snippet is in below: def MakeNGram(sent_list, N, vocab_size, seq_size): NGramList = [] for sent in ...
Maryami Najafi's user avatar
1 vote
1 answer
219 views

LSTM InvalidArgumentError

I'm trying to implement both character and word lstms but i keep getting this error: InvalidArgumentError: indices[310,0] = 119 is not in [0, 119) [[node model_3/time_distributed_12/embedding_7/...
mojbius's user avatar
  • 95
0 votes
1 answer
779 views

Exact details of Embedding layer in Keras

I want to understand the Embedding layer in Keras. Can anyone help? I cannot find any good reference. Which algorithm is working? I mean based on which paper or method? I want details to implement it ...
user avatar
1 vote
1 answer
1k views

Why keras Tokenizer with unknown token requiring embedding's input_dim to be vocab_size +2, instead of vocal_size+1

I am working with keras embedding and using Keras tokenizer. At first, I wasnt using oov_token (for unknown token) and I was having length of my tokenizer's word_counts as 54. For embedding I used to ...
A.B's user avatar
  • 20.4k
0 votes
1 answer
289 views

why seq2seq model return negative loss if I used a pre-trained embedding model

I am following this example code to build a seq2seq model using keras. https://github.com/keras-team/keras/blob/master/examples/lstm_seq2seq.py when I train that code it works normally fine and the ...
Kamal El-Saaid's user avatar
0 votes
1 answer
176 views

Word Embedding for text classification [closed]

I am new in the NLP community and need more light on something. I saw that Keras has an Embedding layer that is generally used before the LSTM layer. But what algorithm hides behind it? Is it Word2Vec,...
Thomas Hustache's user avatar
1 vote
1 answer
208 views

Tensorflow Error Concatenating Char and Word embedding

I want to concatenate Char Embeddings (generated using CNN) with my Word Embedding (using Glove vectors) but getting the error since the shape of Char Embeddings is different from Word Embeddings. How ...
Kushal Vijay's user avatar
5 votes
0 answers
695 views

Incorporate fasttext vectors in tf.keras embedding layer?

Fasttext could handle OOV easily, i.e., it could be assumed that emb = fasttext_model(raw_input) always holds. However, I am not sure how I could build this layer into tf.keras embedding. I couldn't ...
Mr.cysl's user avatar
  • 1,614
0 votes
1 answer
115 views

dimension of the input layer for embeddings in Keras

It is not clear to me whether there is any difference between specifying the input dimension Input(shape=(20,)) or not Input(shape=(None,)) in the following example: input_layer = Input(shape=(None,))...
user avatar
0 votes
0 answers
109 views

ValueError: Input 0 of layer lstm_34 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 25]

I am a newbie with lstm, can anyone please explain why I am getting this error? my lstm model - def NNStructure(): input_text = tf.keras.Input((), dtype = tf.string, name = 'input_text') initial_input=...
konika jahan's user avatar
0 votes
1 answer
61 views

Dynamic name formatting with epoch number for .tsv file creation

I 've made this custom callback in Keras for obtaining the embedding vectors at the end of each epoch. It should save the vectors on a .tsv which it does but since the name does not update on each ...
Tasos Asonitis's user avatar
1 vote
1 answer
1k views

Should BERT embeddings be made on tokens or sentences?

I am making a sentence classification model and using BERT word embeddings in it. Due to very large dataset, I combined all the sentences together in one string and made embeddings on the tokens ...
PeakyBlinder's user avatar
  • 1,117
1 vote
1 answer
168 views

Exporting embeddings per epoch in Keras

I am trying to get access to the output of the embedding layer (the n-dimensional vectors) in Keras on a per epoch basis. There doesn't seem to be a specific callback for this. I 've tried the ...
Tasos Asonitis's user avatar
1 vote
0 answers
175 views

Validation loss/accuracy always struck at certain threshold in LSTM

I have a sequence prediction problem in which, given the last m items(6) in a sequence I need to predict next item. There are N=60k sequences for now and for each sequence n, I have 6 events and I ...
A.B's user avatar
  • 20.4k
2 votes
0 answers
260 views

Generate equidistant multidimensional vectors as Embedding matrix

I need to generate an embedding matrix to use instead of the layer. I know a priori the similarity between the 10 features (all equidistant from each other) and I can't generate the matrices through ...
Nixiam's user avatar
  • 43
1 vote
0 answers
105 views

keras embedding layer modification for multiple time-steps with one feature

I have a sequence prediction problem in which, given the last n items in a sequence I need to predict next item. There are N=60k sequences for now and for each sequence n, I have 6 events and I want ...
A.B's user avatar
  • 20.4k
6 votes
1 answer
9k views

Using BERT Embeddings in Keras Embedding layer

I want to use the BERT Word Vector Embeddings in the Embeddings layer of LSTM instead of the usual default embedding layer. Is there any way I can do it?
PeakyBlinder's user avatar
  • 1,117
0 votes
1 answer
352 views

I got Assertion Error when fitting a model in Keras after concatenating Embedded layers

I am new with Embedded Layers and I have a problem with that. I was trying to fit a neural network model, but first I encoded the categorical features of my dataset with an Embedding layer. Here is my ...
jartymcfly's user avatar
  • 2,005
0 votes
1 answer
706 views

How to chain an input layer to tensorflow-hub?

I want to classify text to 2 classes by using this embedding: https://tfhub.dev/google/universal-sentence-encoder-multilingual/3 And I also want to add additional features after the embedding. So I ...
user3876608's user avatar