Questions tagged [keras]

Keras is a neural network library providing a high-level API in Python and R. Use this tag for questions relating to how to use this API. Please also include the tag for the language/backend ([python], [r], [tensorflow], [theano], [cntk]) that you are using. If you are using tensorflow's built-in keras, use the [tf.keras] tag.

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Keras accuracy does not change for multi-output module

I've only just started learning about keras and machine learning modules, so bear with me even if my code looks full of inefficient stuff and inaccuracies. So basically, what I want to make my ml ...
Aliquis's user avatar
0 votes
0 answers
14 views

Converting HuggingFace Tokenizer to TensorFlow Keras Layer

I am struggling to understand how to perform inference with a pre-trained HuggingFace model loaded as a TensorFlow Keras model. Context In my case, I am trying to fine-tune a pre-trained DistilBert ...
AndrewJaeyoung's user avatar
0 votes
0 answers
10 views

Extracting an item from a TensorFlow InputLayer

I am building a neural network with an input layer, a dense layer and an output layer. I'd like to use a number from the input vector in my custom loss function. Let's say I have the following loss ...
G. C.'s user avatar
  • 47
0 votes
0 answers
12 views

How to deal with None shape sizes in a custom layer whose output size should be half the input size?

When writing a custom layer in Keras with the input of shape (BatchSize, Height, Width, NumChannels) it should output a shape of (BatchSize, Height // 2, Width // 2, NumChannels), but I'm not sure how ...
Lenny's user avatar
  • 113
0 votes
0 answers
16 views

How to compute GradCAM for keras regression model with multiple outputs

I have build a DenseNet121 that has 5 regression output layers. The code to build the model looks like this: base_model = DenseNet121(include_top=False, input_shape=(224, 224, 3), weights="...
ManuJo's user avatar
  • 1
0 votes
0 answers
11 views

keras tuner does not create checkpoint files

I used keras tuner in direct approach in time series forecasting on VScode on windows11. I attempted to predict values for 7 days in the future, and created 7 models for each day. I created a tuner 7 ...
Ten's user avatar
  • 43
0 votes
0 answers
74 views

Why does the one-hot-encoding give worse accuracy in this case?

I have two directories, train_data_npy and valid_data_npy where there are 3013 and 1506 *.npy files, respectively. Each *.npy file has 11 columns of float types, of which the first eight columns are ...
user366312's user avatar
  • 16.9k
0 votes
0 answers
24 views

How to plot Learning Rate and Epoch when training a CNN?

I am trying to use a cosine-based decay schedule to improve the accuracy of my CNN. I want to visually see the changes that are made to the model's learning rate by this schedule throughout the ...
Mateo del Rio Lanse's user avatar
-1 votes
0 answers
9 views

Custom TensorFlow Layer Object: NameError: name 'myLayer' is not defined

I'm new to TensorFlow/Python and stuck on this simple class initialization. Any help is appreciated. %tensorflow_version 2.x import tensorflow as tf from tensorflow import keras from keras import ...
identityCrisis's user avatar
0 votes
0 answers
10 views

Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'int'>"}). How to fix?

import numpy as np import tensorflow as tf from pickle import load from numpy import argmax from keras.preprocessing.text import Tokenizer from keras.preprocessing.sequence import pad_sequences from ...
Sanjit Sai Kolla's user avatar
-1 votes
1 answer
38 views

Tensorflow broadcastable shapes

I'm fitting this neural network with Tensorflow 2.10.1 but I get an error when using the last batch that has a smaller size [22, 40, 40, 1] than the others [32, 40, 40, 1] The network is defined as ...
Alessandro Bitetto's user avatar
0 votes
0 answers
5 views

Why does this input shape Not match the Keras model and my data?

I am struggling to see why Keras can Not load my data into a simple Sequential model. All I want to do is load the data that looks like this: So I have 8295 samples, each sample is made up of 400 data ...
Ashish Patel's user avatar
0 votes
0 answers
29 views

How do i get the feature map of keras CNN model?

I want to know if there is a way to retrieve/save the feature map results on the CNN model. I also want to add the threshold = 0.03, how can I do it? Here is my code face_train_generator = ...
ELANG's user avatar
  • 1
0 votes
0 answers
28 views

MNIST not outputting correct prediction - school project

I created a simple python script that will open a small window and allow user to draw a digit 1-9. When I test it, it continuously outputs the wrong number but says it is 98% accurate when training. ...
Shawn's user avatar
  • 23
-1 votes
0 answers
14 views

Make model from Keras subclassing()

Is there anyone know how to make model from transformer into Keras model using subclassing()? I tried so many ways but failed, so i hope there will be someone understand and give me advice how to use &...
Gabriel Fernando's user avatar
1 vote
1 answer
28 views

How to manipulate NN output shape for array input data

I am new to machine learning in python and I am trying to debug an error that i am getting when it comes to manipulating the sizes and shapes of layers for a simple DQN model that guesses letters in a ...
potatopowered's user avatar
-2 votes
0 answers
28 views

The model.tflite produces different results on Python and Android

I couldnt exactly figure out what the problem is. I'm trying to make a prediction with a data input consisting of 145 numbers, and my model produces accurate results in Python. However, when I load ...
Mehmet DİRİER's user avatar
0 votes
0 answers
24 views

Is it possible to make a custom for regression loss function in keras considering the previous output

I am building a CNN image regression model. I want to put a penalty term in the loss function to penalize if the current prediction is greater than the previous expectation. My question is that is ...
Minsung Kang's user avatar
-1 votes
0 answers
22 views

ValueError: Shapes (None,) and (None, 3052, 3) are incompatible

max_words=70000 token_text=Tokenizer( num_words=max_words, filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n', lower=True, split=' ', char_level=False,`enter code here` oov_token=None, ...
PRITAM BHAKTA's user avatar
0 votes
0 answers
10 views

how can we manage the out put shape from datagen in data augmentation?

I'm engaging the CNN network. because of high volume of data, I'm using data generator. i engaged data augmentation in data generator function. i determine the batch size as 10, when i wanna run the ...
sara_sh's user avatar
0 votes
0 answers
19 views

Error: Unrolling requires a fixed number of timesteps - LSTM - recurrent dropout

I am working with an LSTM model on time series data. My idea is to add recurrent dropout to the LSTM layer to mitigate overfitting. By default, Keras uses a cuDNN kernel to optimize training. ...
JorgeDC's user avatar
-2 votes
0 answers
12 views

Difference between Original Vision Transformer script and Keras code example Vistion Transformer script

I am a graduate student, and currently, I am attempting to test our team's dataset, which we analyzed with CNN pre-trained models using the Original Vision Transformer script. Starting with the ...
godoldol's user avatar
-1 votes
0 answers
15 views

Issue with implementing Attention mechanisms for Text Classification

I'm trying Attention mechanisms for the first time I'm Unable to understand the use of Attention and MultiHeadAttention from keras. (Confusion in Implementation, Conceptually its clear) Few of my ...
Eswar T's user avatar
  • 181
0 votes
0 answers
47 views

TensorFlow.js MLP Regression Model output not returning as expected

I've created a MLP Regression Model with TensorFlow.js that takes as input a tensor like this: tf.tensor2d([[1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 8]]) The Model was constructed this way: function ...
Tamtuza's user avatar
  • 11
0 votes
0 answers
16 views

ValueError: The two structures don't have the same nested structure. while loading a roberta model

I used the following roberta sentiment model to and fine tuned it to my text data. roberta_model = TFAutoModelForSequenceClassification.from_pretrained('cardiffnlp/twitter-roberta-base-sentiment') ...
Aryan Ramani's user avatar
-1 votes
0 answers
13 views

Addressing Inconsistent Quality in LSTM Forecast: Early Sequence Output Issues

I'm currently working on a time series forecasting project using a LSTM encoder-decoder model. The model is designed to return a sequence as output. However, I'm facing an issue where the quality of ...
Ali's user avatar
  • 144
0 votes
0 answers
13 views

KerasTensor to Tensor

I am working on a image classification problem using a transformer model with linear self-attention. I get a type error stating: "TypeError: linear(): argument 'input' (position 1) must be Tensor,...
Deandre Way's user avatar
-1 votes
0 answers
21 views

AttributeError: module 'keras.api._v2.keras.layers.experimental.preprocessing' has no attribute 'RandomBrightness'

AttributeError: module 'keras.api._v2.keras.layers.experimental.preprocessing' has no attribute 'RandomBrightness' while data augmentation , preprocessing.RandomBrightness(0.2), preprocessing....
Akteruzzaman Ashik's user avatar
0 votes
0 answers
45 views

How to interpret the shapes given by summary() in a sequential model?

I'm new to Keras. This is my code: import tensorflow as tf import keras # model 1 model1 = keras.Sequential([ keras.layers.Dense(3, "relu"), keras.layers.Dense(1) ], name="...
qseb59's user avatar
  • 11
0 votes
1 answer
41 views

model.fit Error for multiclass classification

Getting a long error message, and I don't know what it means. Maybe trying x_train = x_train / 255.0 which affects the model.fit call? The error is at the model.fit line. from keras.datasets import ...
keith's user avatar
  • 15
-2 votes
0 answers
20 views

ValueError: `decode_predictions` expects a batch of predictions (i.e. a 2D array of shape (samples, 1000)). Found array with shape: (None, 4) [closed]

When i pass decode_prediction it returned array shape from keras.applications.vgg16 import preprocess_input,decode_predictions predictions = vgg16model.predict(preprocessed_image) decoded_predictions =...
MERAZ ALI's user avatar
0 votes
1 answer
23 views

Attention Layer changing Batch Size at inference

I have trained seq-to-seq model using Encoder-Decoder architecture. I'm trying to produce an output sequence given an input context, and I am trying to do that on a batch of input context vectors. I ...
Krishnang K Dalal's user avatar
1 vote
1 answer
36 views

Is it possible to normalize each individual kernel input to a Conv2D in keras?

Using tf.keras I have a Conv2D layer with a kernel size of say 5x5. Is it possible to have each 5x5 patch be normalized by the L1 norm (or potentially any other transformation on that patch) before it ...
Lenny's user avatar
  • 113
1 vote
0 answers
26 views

How to make a convolution layer which feeds from the local neighborhood of a staggered grid?

I'm new to keras, so maybe I'm simply missing an important point, but I was not able to specify a Conv2D layer, which would feed from a 2D staggered grid. My staggered grid is defined as one 2D array ...
Lenny's user avatar
  • 113
0 votes
1 answer
10 views

Installing Keras for R - how might I solve an error message when installing Keras (ImportError: DLL load failed while importing _ctypes)?

I'm trying to install Keras for R My professor gave me this link to download it: https://hastie.su.domains/ISLR2/keras-instructions.html I get an error message after I run the 3rd line of code: `...
Yuri's user avatar
  • 1
0 votes
0 answers
25 views

Data preprocessing tuning with keras BayesianOptimization tuner

I'm working on a multivariate timeseries vanillaLSTM model where the input shape is (n_samples,past_steps, n_features), It's a single step output model. I'm trying to do hyperparameter tuning for it ( ...
Omar Alqaysi's user avatar
0 votes
0 answers
11 views

Reset ram usage in google colab after training a neural network

I am training in leave one-out validation a neural network. At the end of every session of training in google colab pro+ the ram is not resetting and when I start the next training I have already busy ...
Pitone's user avatar
  • 43
-2 votes
0 answers
25 views

Mis-classification of CNN on single image randomly outside of model predictions, while training, val and test accuracy is 1 [closed]

Built a simple CNN with 4 classes angry, excited, happy and sad. Total dataset 325 almost equally balanced btw all 4 classes. My training and validation loss decreased throughout 20 epochs and ...
Bhavya Mehra's user avatar
0 votes
0 answers
35 views

Get values of 'model.fit' keras API parameters

I am trying to get detailed information of the Kera sequential model using a customized callback function. I need to extract all values of the parameters set in model.fit() API such as batch_size, ...
Mehdi's user avatar
  • 83
-1 votes
0 answers
51 views

No module named 'keras.engine' when I try to import Mask R-CNN on Google Colab

I'm trying and learning how to use Mask R-CNN on my own dataset. So, i've tried to import the model on Colab in this way: !pip install mrcnn-colab from mrcnn.config import Config from mrcnn import ...
setzin's user avatar
  • 1
1 vote
1 answer
41 views

Is there a way to make sure that the first kernel used by Conv2D is the same every time?

I am reading about keras as part of an assignment and my supervisor has asked me to see if there is a way initialize Conv2D with the same set of kernels every time. Note: I am not building a model yet,...
user385323's user avatar
0 votes
0 answers
18 views

Unknown optimizer: 'additionalupdatesoptimizer' error Using Keras-Rl2 and tensorflow on Mac M1Pro

So I'm using: tensorflow 2.13.0 (Tried to use tensorflow-macos 2.12.0 got the same error) keras-rl2 1.0.5 numpy 1.23.5 I'm working on OpenAI's gym, and get this error: File "/Users/tima/AI/...
Темирлан Асанов's user avatar
0 votes
0 answers
45 views

L1 regularisation not working for linear regression

L1 regularisation not working for linear regression, here in below example I have created a data as y = 2x1 + 5x2 + 3*x3 + 5 Here in dataset x4 parmeter is there, but to calculate the output in ...
Nitul's user avatar
  • 1,005
0 votes
1 answer
68 views

Manually perform predictions using the model weights and biases (Keras)

I'd like to manually predict data (regression task) using the model weights and biases in Keras (i.e., Z = f(WX+B), where Z is the output of a layer, W is the weight matrix, X is the input vector, and ...
Ronald Cabaoig's user avatar
-1 votes
0 answers
16 views

Modifying ml tutorial code from google does not give expected result

There is a nice mini example for ml python code using tensorflow lib. Tutorial at google code labs It's (correctly) predicting a number from a linear equation. But just making a small mod to have the ...
Gert Gottschalk's user avatar
0 votes
0 answers
50 views
+100

Why is this AutoKeras NAS failing?

I am using nVidia GeForce GTX 780 (Kepler) Driver Version: 470.223.02 CUDA Toolkit v11.4.0 cuDNN v8.2.4 TensorFlow and Keras v2.8.0 AutoKeras v1.0.17 Ubuntu 20.04 ======================= I have two ...
user366312's user avatar
  • 16.9k
0 votes
0 answers
22 views

layers.Input in tensorflow -- TypeError: list indices must be integers or slices, not str

TLDR: I need this to work with the exact version of tensorflow (EfficientPose) mona@ada:~/EfficientPose$ python evaluate.py --phi 0 --weights weights/Weights/Linemod/object_8/phi_0_linemod_best_ADD.h5 ...
Mona Jalal's user avatar
  • 35.5k
0 votes
0 answers
11 views

tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [5,3] vs. [5]

I am trying to compose a cVAE model in keras. However, I keep getting the error: tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [5,3] vs. [5] [[{{node training/Adam/...
Xueyuan Cao's user avatar
0 votes
0 answers
19 views

How the RecommenderNet model works?

I'm implementing a RecommenderNet model with data of 100 users, 27 locations, and 1170 reviews. I want to know how the model works why dot product is used between user_vector and movie_vector, like ...
Khang Khang's user avatar
0 votes
0 answers
41 views

What is the difference between Sequential and Concatenate of keras while creating input for model?

What is the difference between Sequential and Concatenate of keras while creating input for model? I have seen two way of creating layers with Sequential where we just define the shape of the input, ...
Nitul's user avatar
  • 1,005

1
2 3 4 5
848