1,510 questions
3
votes
1
answer
43
views
How to fix ValueError: Only instances of keras.Layer can be added to a Sequential model when adding tensorflow_hub.KerasLayer?
I am learning TensorFlow and transfer learning, and I am trying to add a TensorFlow Hub feature extractor to a Keras Sequential model. But I get this error:
ValueError: Only instances of keras.Layer ...
-1
votes
1
answer
71
views
Keras: how to avoid input shape of sequential call being automatically squeezed by input
When creating a sequential MLP taking a batched input of shape [batch,n_channels,1], calling keras.layers.Input forcibly squeezes the last axis resulting in issues in an NN i'm attempting to create ...
-2
votes
1
answer
586
views
ValueError: Only instances of 'keras.Layer' can be added to a Sequential model
ValueError: Only instances of `keras.Layer` can be added to a Sequential model.
Received: <tensorflow_hub.keras_layer.KerasLayer object at 0x7c61f819f590>
(of type <class 'tensorflow_hub....
0
votes
0
answers
49
views
Layers error while trying to use keras_vggface
I get this error with trying to run my code:
Traceback (most recent call last):
File "/Users/kegak/AI_Project/main.py", line 24, in <module>
vggface = VGGFace(model='resnet50', ...
2
votes
0
answers
27
views
Finetuning with Loraa and fitting my model error
After finetuning my dataset using keras, I tried to fit the model to lora and this was the error I encountered:
TypeError Traceback (most recent call last)
Cell In[12], ...
2
votes
1
answer
314
views
Keras Error 'keras.layers' has no attribute 'RandomRotation'
I am trying to optimize a CNN made with KERAS. For that I wanted to use the KERAS TUNER module. However, when importing the module i get the error message: "AttributeError: module 'tensorflow....
1
vote
4
answers
2k
views
Only instances of `keras.Layer` can be added to a Sequential model
I encountered an error related to Sequential while working with TensorFlow Hub. Can anyone help me with this?"
enter image description here
"ValueError: Only instances of keras.Layer can be ...
0
votes
0
answers
79
views
ValueError: Layer 'functional_45' expected 3 input(s). Received 1 instead. Trouble with passing validation dataset
I am new to Tensorflow and kKeras and I am trying to create a neural network as mentioned in the keras website.
I am trying to create a baseline model with a dataset of my own.
The codes are exactly ...
0
votes
1
answer
59
views
Trying to concatenate two keras tensors but getting error
I'm trying to concatenate a tensor with shape (None, 11, 1, 1) with another tensor with shape (None,1,1,1). Reading the keras.layers.Concatenate() docs I understood that the shape should be the same ...
0
votes
1
answer
207
views
Value error in passing batch_input_shape Argument in Keras Embedded Layer
I am having trouble with passing "batch_input_shape" in Jupyter Lab and VScode as well.
### Defining the RNN Model ###
def LSTM(rnn_units):
return tf.keras.layers.LSTM(
rnn_units,
...
0
votes
1
answer
159
views
Is YAMNet model can be used with the hub.KerasLayer?
I am attempting to use YAMNet for transfer learning to perform speech command recognition. I plan to train the model using the mini speech commands dataset from the simple audio project. The goal is ...
0
votes
1
answer
788
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))
...
0
votes
0
answers
830
views
AttributeError: module 'keras._tf_keras.keras.layers' has no attribute 'experimental'
i'm new to tensorflow and keras and i'm trying to build a realtime sign detection model.
I'm following Nicholas Renotte's video tutorial https://www.youtube.com/watch?v=pDXdlXlaCco&t=864s
import ...
1
vote
2
answers
552
views
Error when using keras: module 'keras.layers' has no attribute 'TextVectorization'
import os
os.environ["KERAS_BACKEND"] = "tensorflow"
import pandas as pd
import pathlib
import random
import string
import re
import numpy as np
import tensorflow as tf
import ...
3
votes
1
answer
2k
views
Tensorflow v2.16 tf.keras.layers Embedding not accepting argument for input_length
While working with Embedding for an LSTM model I came across an issue with input_length:
ValueError: Unrecognized keyword arguments passed to Embedding: {'input_length': 536}
Is input length being ...
0
votes
0
answers
68
views
Problem with keras.Dense. The last dimension of the inputs to a Dense layer should be defined. Found None. Full input shape received: (None, None)
I wrote some python code to develop a siamese network. The sub-clase from keras.Model is:
class modelSIAMESE(keras.Model):
def init(self):
super().init()
input_shape = target_shape + (3,)
input_a = ...
0
votes
1
answer
110
views
Why do my model predictions show zero variance for multiple predictions when using Monte-Carlo dropout?
I am working on an image segmentation CNN using Keras (pytorch backend if that matters). I am basing my code off the UNET segmentation code (here which utilizes Monte-Carlo dropout during predictions ...
0
votes
0
answers
54
views
ModuleNotFoundError when importing Sequential from Keras
I’m encountering an issue when trying to import the Sequential class from Keras. Here’s the code I’m running:
from keras.models import Sequential
from keras.layers import Embedding, LSTM, Dense
model ...
0
votes
1
answer
37
views
ValueError: Input 2 of layer "full_model" is incompatible with the layer when creating a multi-view Variational Autoencoder model using Keras
I want to implement a multi-view Variational Autoencoder (VAE) model using Keras. The
Code:
import tensorflow as tf
from tensorflow.keras import layers, models
from tensorflow.keras.utils import ...
0
votes
0
answers
32
views
ValueError in shape - prediction with keras.models.Sequential
When executing the following code to predict the category of an image using a model trained using the fashion MNIST dataset, the following error occurs. How can I fix this error? Any advice would be ...
3
votes
0
answers
97
views
Custom layer at top of Tensorflow model
I want to add a Custom Layer to a Tensorflow Model which transforms every row of a the input set to the model in a set pattern.
For example, below is the custom layer than I have:
class CustomLayer:
...
1
vote
1
answer
364
views
Gradients do not exist for variables in custom layers in TensorFlow
I am trying to build a custom 1D convolution layer in TensorFlow. I have checked that the layer does what is supposed to do. However when I insert it in a sequential Keras model I get that WARNING ...
0
votes
1
answer
333
views
Export tensorflow.keras.Sequential model as FMU file
I've trained a neural network and am looking to save it as an FMU (Functional Mock-up Interface)file
import tensorflow as tf
from tensorflow.keras import layers, models, optimizers,initializers
model =...
-3
votes
1
answer
389
views
keras model.add NameError: name 'input_shape' is not defined
i am following a yt tutorial and my programm shows "NameError: name 'input_shape' is not defined"
did i forget to import something ?? or did the name change of the 7 months since this video ...
0
votes
1
answer
36
views
Custom Layer in TensorFlow/Keras
I'm new to tensorflow and I'm trying to build a custom layer that takes multiple inputs (namely, x,y,A) and return z. In this layer, w is the trainable parameter. my code is:
import tensorflow as tf
...
1
vote
1
answer
158
views
How to add random value to each weight of a Keras model
I got a nontrivial model with several nontrivial layers for which I'd like to do the following:
I create a random vector of values v with length equal to the number of parameters of the model.
Now I'd ...
3
votes
1
answer
557
views
How to obtain all layers within a custom layer subclassed from keras.layers
I'm trying to get all layers from within a custom layer subclassed from tf.keras.layers but I am having difficulties with this. The end goal is to create a DAG (Directed Acyclic Graph) that has layers ...
1
vote
0
answers
31
views
Extracting intermediate layer of saved model in keras. That intermediate layer is another sub-model defined in main model
Here is my architecture.
def model1():
inputs = layers.Input(shape=(x1.shape[-2],x1.shape[-1]), name='Input_layer')
x = layers.Reshape((x1.shape[-2], x1.shape[-1], 1), name='Input_reshape')(...
0
votes
0
answers
35
views
How to count int-type 1D when the model returns 2D?
I'm newbie to reinforcement learning. I'd like to see and understand the code that predicts Kerath's actor critic value, and then run it with some changes.
my code is simple code without normalization,...
1
vote
2
answers
536
views
Exception encountered when calling layer and 'KerasTensor' object is not callable
I'm newbie to reinforcement learning.
I'd like to see and understand the code that predicts Keras actor critic value, and then run it with some changes.
Example code: https://github.com/keras-team/...
1
vote
0
answers
103
views
How to pass multiple embedded layers into TFDF using Keras?
In the Keras tutorial it shows how to embed a text field and pass it to TFDF in this tutorial.
sentence_encoder_layer = hub.KerasLayer(
"https://tfhub.dev/google/universal-sentence-encoder/4&...
1
vote
0
answers
20
views
Keras functional API can not save right weights in h5 files
I have used functional API to build a ResNet neural network algorithm. However, this constructed model can not save the neural networks' weights in an appropriate result. The validated result was very ...
0
votes
1
answer
243
views
Unpickling model in Google Colab; Received a value_error that dense_50 did not receive the expected variables
I have trained a neural network in Spyder, and it runs wonderfully. In order to make it faster I'm trying to test using GPUs, which is why I switched to Colab. When it unpickles my model, I get this ...
0
votes
0
answers
44
views
How to pass Stellargraph as an input to Keras model?
I am unable to pass Stellargraph graph as an input to Keras model using Input().
It gives an error:
Failed to find data adapter that can handle input: <class 'stellargraph.core.graph.StellarGraph'&...
0
votes
0
answers
113
views
Keras binary classification on multiple outputs
My goal is to design and train a model to detect points of derivative discontinuity in a line profile. The input data of my model are 1D vectors, with some geometrical shapes [as shown in Fig 3], one ...
-1
votes
1
answer
3k
views
ValueError: Unknown layer: 'CustomScaleLayer'. Please ensure you are using a`keras.utils.custom_object_scope`
tensorflow version : t2.13.0-rc1
import os
import cv2
import numpy as np
import pandas as pd
import tensorflow as tf
import pytesseract as pt
import plotly.express as px
import matplotlib.pyplot as ...
1
vote
0
answers
1k
views
Data augmentation using keras.layers.RandomRotation() doesnt yield same results
In my project I have dataset of original images and correcponding masks. I want to perform augmentation so it is random, yet same for image and matching mask. For this I have defined keras sequential ...
0
votes
1
answer
1k
views
Understanding tf.keras.layers.Dense()
I am trying to understand why there is a difference between calculating a dense layer operation directly and using the keras implementation.
Following the documentation (https://www.tensorflow.org/...
2
votes
0
answers
116
views
How to send input multiple columns data to keras model?
Given a numpy database of size (128, 47088), I need to send a data sequence to the training model, for example:
This image is a sample for illustrative purposes only
Send the data from columns 0, 1, 2,...
0
votes
0
answers
57
views
How to concatenate 3 parallel dense layers?
I want to concatenate 3 parallel layers each with Input(shape=(1,)) for multiclass classification.
_______
input_1(feature[10000,0])----> dense ----> |...
1
vote
0
answers
43
views
Keras tensorflow Model not returning Map with UserDefined Keynames
I am new to Keras API , I am able to get Map as response but i am not able to get userdefined key names in response For Ex: My Expected response is
{
"predictions": [
{
...
1
vote
1
answer
95
views
Can't add random noise to weights inside a Keras Layer
I am trying to add a random noise during forward pass to a convolutional layer in Keras. I wrote a wrapper class where it would add noise to the weights before computing convolution. Any addition or ...
0
votes
0
answers
51
views
How can I code an equation in a custom layer using keras?
Equation to be coded
Model showing what the equation does
I would like to be code the equation attached in a custom layer. This layer will accept inputs of dimensions (None,3) & (None,37,3) and ...
2
votes
0
answers
520
views
Conversion of a Tensorflow Model with Preprocess layer to TFLite
I'm trying to build a TFLite Audio Classification Model and for that I have integrated Preprocess Function with the Model in a single file.
The following code is to combine my model with the ...
0
votes
2
answers
372
views
How to feed multi head tensorflow model with tf.data.dataset
I'm using for the first time tf.data.dataset to feed a model. I look on some exemple but don't find how to use multi-inputs on a 2 heads model.
My first input as shape[nb_samples, nb_timesteps, ...
3
votes
1
answer
8k
views
modulenot found 'keras.layer.embeddings' i dont have any idea how to fix this even though i installed keras properly
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
from wordcloud import WordCloud
from bs4 import BeautifulSoup
import re
import nltk
...
1
vote
0
answers
166
views
Adding a WordPieceTokenizer to a keras end-to-end model
I have trained a simple classification model based on https://keras.io/examples/nlp/text_classification_from_scratch that uses a WordPieceTokenizer & StartEndPacker to pre-process the input ...
0
votes
1
answer
1k
views
Why is the graph for the 'TFOpLambda' layer's 'call' method not stored in the SavedModel object_graph_def?
I work on importing TensorFlow models into MATLAB, this includes de-serializing the SavedModel format, identifying the different tf.keras.layers present in the SavedModel and creating an equivalent ...
0
votes
1
answer
50
views
Python keras ValueError: ['selam'] is not in list error
I have written a program with Python Keras but it gives the following error:
import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Activation, Dropout
from keras....
0
votes
1
answer
331
views
Adaptive Activation Function in Tensorflow 2 trained variable for mulitple calls
So I want to try out an adaptive activation function for my neural network. This means I want to have a custom loss that is similar to a standard one (like tanh or relu), however I want to add some ...