10,354 questions
0
votes
0
answers
22
views
Looking for CNN sobel filter with No Padding
I'm coding from scratch a very basic CNN, my attempt is not to use AI but forums and documentation.
I want to test out applying the sobel filter without padding but
sobel(input = self.image, mode=None)...
0
votes
0
answers
24
views
How To Work With Windowsize Inputs That Don't Match The Pooling?
Let's take a minimal 1d cnn autoencoder model as an example:
def cnn_session_encoder(inputs):
x = layers.Conv1D(32, 3, activation="relu", padding="same")(x)
x = layers....
Advice
0
votes
0
replies
40
views
Large Kernel in ConvNets
I want to find a convolutional network with a large kernel (larger than 5x5 or 7x7). I want to perform kernel analysis, and to do this, I need to convert the model to the onnx format. I found ...
1
vote
1
answer
132
views
Torch Conv2d results in both dimensions convolved
I have input shape to a convolution (50, 1, 7617, 10). Here, 7617 is word vectors as rows, and 10 is the number of words in columns. I want to convolve column-wise and obtain (2631, 1, 7617, 1), 1 ...
0
votes
0
answers
35
views
Why does MATLAB selfAttentionLayer give different parameter counts for head/key-channel pairs with the same total key dimension?
I’m experimenting with the MathWorks example that inserts a multi-head self-attention layer into a simple CNN for the DigitDataset:
Link to example
layers = [
imageInputLayer([28 28 1])
...
0
votes
0
answers
88
views
GradientTape won't calculate gradients after restoring a model from ModelCheckpoint
I'm training a CNN on Tensorflow for binary classification and executing my code in Google Colab.
CNN_model = tf.keras.Sequential([
tf.keras.layers.Input(shape=(IMAGE_SIZE, IMAGE_SIZE, 3)),
tf....
0
votes
1
answer
35
views
Model with ResNet blocks stuck at low accuracy
I am trying to implement classification of ECG segments from PTB-XL database (https://physionet.org/content/ptb-xl/1.0.3/). The architecture of the model which I am using is:
import torch
import torch....
0
votes
1
answer
74
views
ValueError: The layer sequential_4 has never been called and thus has no defined input
I have built a CNN model with the following layers:
def build_trainable_cnn(input_shape, num_classes):
"""
Create a CNN model for feature extraction
Parameters:
...
0
votes
0
answers
138
views
My ResNet training loop has a CPU bottleneck, A100 GPU is barely utilized regardless of workers num
I'm training a ResNet50 model on 300W-LP dataset with AFLW2000 as a validation dataset.
The task is head pose angle prediction (pitch, yaw, roll) with a 1-bin head output for each angle.
When training ...
0
votes
2
answers
107
views
CNN Constant Predictions
I’m building a Keras model based on MobileNetV2 for frame-level prediction of 6 human competencies. Each output head represents a competency and is a softmax over 100 classes (scores 0–99). The model ...
0
votes
0
answers
20
views
Finetuning MobilenetV3S on Google Colab
Last year I finetuned MobileNetV3S on google colab [tensorflow version 2.15.0] gave me 95% (test) accuracy and loss below 0.25. However, running the same notebook now (2025-05) [tensorflow verion 2.18....
0
votes
0
answers
68
views
CNN predicts constant values for sparse amplitude regression — can't learn true pixel values
I’m training a small CNN (code below) to predict sparse amplitude maps from binary masks.
Input: 60×60 image with exactly 15 pixels set to 1, rest are 0.
Target: Same size, 0 everywhere except those ...
1
vote
1
answer
54
views
How do you properly format data for CNN classification?
I'm trying to use LeNet to classify univariate time series data with 300 time steps.
num_channels = 1;
num_classes = 3;
filterSize = 5;
numFilters = 32;
num_of_features = size(X_train(1, :), 2);
...
0
votes
1
answer
141
views
How to format input data for Pytorch?
I have written a conv. neural network from scratch before, but I've decided to use Pytorch for its speed. However, I could not find documentation as to how to format for the conv2d layer. In general, ...
8
votes
0
answers
87
views
How to use graph convolutional neural network (GCNN) to predict the appropriate patterns to solve an scheduling problem
I am working on a scheduling problem where I am willing to solve that by Graph Convolutional Neural Network (GCNN). The problem is stated as follows:
There is an assembly product graph with $\text{G(V,...
-1
votes
1
answer
62
views
Why is my loss value increasing when I update the biases? [closed]
I am currently working on a convolutional neural network in python, and I am currently implementing back propagation. As of now I am just implementing it for the output layer, and I just wrote the ...
1
vote
1
answer
97
views
Yolo v11 obj detection custom inference gives totally different results than yolo cli predict
I am trying to run an exported version of a fine-tuned yolov11n to detect road signs. When I run the model with the yolo cli on this exact same image, I get an object detected with confidence 0.86. ...
0
votes
1
answer
87
views
How Can I Get Positive Responses Only from a Neural Net?
I'm using TensorFlow. I have many simulated datasets for which values are real. Each one consists of 200 rows and two columns (variables). I'm using a convolutional neural net. I want the simulated ...
0
votes
0
answers
39
views
Can I use test-time training with audio augmentations (like noise classification) for a CNN-BiGRU CTC phoneme model?
I have a model for speech audio-to-phoneme prediction using CNN and bidirectional GRU layers. The phoneme vector is optimized using CTC loss. I want to add test-time training with audio augmentations. ...
0
votes
1
answer
65
views
Flutter TFLite Model Predictions Wrong Despite Matching Python Preprocessing (Works in Python)
I'm struggling with a Flutter + TFLite integration.
I have a trained TFLite model (EMNIST-like for handwritten letters), and it works perfectly when I test it in Python — but in Flutter, the ...
0
votes
1
answer
68
views
Why does TimeDistributed(Flatten()) raise an InvalidArgumentError when reshaping works?
I'm building a lip-reading model using tensorflow.keras and getting an error when applying TimeDistributed(Flatten()) after my Conv3D layers. Here's a simplified version of my model architecture:
CODE
...
0
votes
1
answer
48
views
Transposed convolution 2D with stride > 1
I was reading pytorch docs about Conv2DTranspose on https://pytorch.org/docs/stable/generated/torch.nn.ConvTranspose2d.html#torch.nn.ConvTranspose2d, and I was curious as to what happens if we ...
1
vote
0
answers
360
views
DNN library initialization failed [[{{node StatefulPartitionedCall}}]] [Op:__inference_multi_step_on_iterator_7615]
I'm learning how to use keras to make a CNN. I'm having trouble and get the following error a DNN library initialization failed on colab for my code and I'm not quite sure why, I modified this code ...
0
votes
0
answers
62
views
How can l solve the input data size problem of vcc16
I'm trying to train pcam dataset in vcc 16 model, but I keep getting this error:
RuntimeError: Given groups=1, weight of size [96, 3, 3, 3], expected
input[256, 96, 3, 96] to have 3 channels, but ...
0
votes
0
answers
63
views
Error: Arrays have incompatible sizes for this operation during Grad-Cam for 3D CNN (MatLab)
I'm trying to apply the Grad Cam technique to a 3D CNN (ResNet101). To do this, I'm trying to use the following code:
dlImg = dlarray(single(img), 'SSSCB');
softmaxName = 'sofctmax';
...
0
votes
0
answers
32
views
generating dynamic sized mel spectrograms based on song duration
I have song files that varies in duration. I am trying to generate their mel spectrograms for training a CNN model afterwards. Since songs contain many frequencies over relatively short duration, ...
0
votes
1
answer
135
views
CNN Autoencoder takes a very long time to train
I have been training a CNN Autoencoder on binary images (pixels are either 0 or 1) of size 64x64. The model is shown below:
import torch
import torch.nn as nn
import torch.nn.functional as F
class ...
1
vote
1
answer
317
views
Why does setting torch.backends.cudnn.deterministic = True make my TCN model extremely slow in PyTorch?
I encountered a very interesting issue when training a deep learning model using Python and PyTorch. I designed a simple TCN as follows:
import torch
import torch.nn as nn
class TCN(nn.Module):
...
0
votes
0
answers
86
views
In my Tensorflow model, why is the output of this concatenation the wrong shape? It should be (Batch size, 14850) but its (Batch size, 1053)?
After passing an input sequence to a 1D CNN, I'm trying to combine the output with some engineered features about the sequence. The input sequence is shape (29,1) and the input to the model is (...
0
votes
1
answer
135
views
CNN-1D for time-series data returns strange accuracy [closed]
I am using keras to train a 1D CNN with time-series as input data to perform a binary classification. The model part of the code is the following:
modelo = Sequential()
modelo.add(Conv1D(filters=32, ...
0
votes
0
answers
31
views
Conv1d vs conv2d
I have several images for one sample. These images are picked randomly by tiling a high-dimensional bigger image. Each image is represented by a 512-dim vector (using ResNet18 to extract features). ...
-1
votes
1
answer
69
views
ImageDataGenerator is throwing Invalid Argument Error
I am working on an Image classification problem with ImageDataGenerator from the keras library. Here is what my script looks like
datagen = ImageDataGenerator(rescale=1./255, validation_split=0.2)
...
1
vote
1
answer
440
views
RuntimeError: Given groups=1, weight of size [64, 3, 3, 7, 7], expected input[1, 8, 3, 112, 112] to have 3 channels, but got 8 channels instead
import os
import shutil
import random
import torch
import torchvision.transforms as transforms
import cv2
import numpy as np
from torch.utils.data import Dataset, DataLoader
import torch.nn as nn
...
1
vote
0
answers
35
views
CNN Model learning improperly returning extrema values
I've been working on a binary object detection CNN model using transfer learning with keras' built in resnet 50 model. However after multiple times of training over 100 epochs it is returning ...
-1
votes
1
answer
139
views
How can I perform image clustering effectively?
I have images of graph lines with trends, and I want to cluster similar trends together. However, after trying several clustering algorithms, they are not working as well as I expected. I believe that ...
0
votes
0
answers
40
views
I am facing an issue in 'input shape' when I am trying do data augmentation
dataset_path = "/content/PetImages"
dataset = tf.keras.utils.image_dataset_from_directory(
dataset_path,
batch_size=32,
image_size=(224, 224), # Resize images
shuffle=True
)
...
1
vote
0
answers
94
views
Non deterministic behavior of a CNN network after adding self attention
When I added NLBloclos, a self-attention layer to my network (simple CNN) the result of the network was not reproducible anymore, when I trained it again, the result was different. But when I remove ...
0
votes
1
answer
79
views
Using tf.keras.utils.image_dataset_from_directory mismatches labels on the images
Here's the code
train_dset = image_dataset_from_directory(
directory = data_path,
batch_size = 32,
image_size = (256,256),
label_mode = "int",
shuffle = True
)
in ...
0
votes
1
answer
26
views
Input 0 of layer "conv2d" is incompatible with the layer: expected min_ndim=4, found ndim=2. Full shape received: (None, 4)
I'm making a CNN and I don't know the full ins and outs of coding. When i try to add the layers, it constantly gives me a "NotImplmentedError" and a "ValueError" that says ...
0
votes
0
answers
54
views
Different results on f-1 score in binary classification task in CNN
I am making a CNN model for binary classification tasks.
When I am using binary_crossentropy as the loss function and keep 1 neuron in the last layer then I am getting around 94% in accuracy and 85% ...
1
vote
1
answer
42
views
How to interpret differences in accuracy curves after applying different data augmentations in CNN training?
I trained a CNN for emotion recognition and used two different transformation pipelines for image preprocessing:
Simple Transformation:
TRANSFORM = transforms.Compose([
transforms.Resize((64, 64)),...
0
votes
0
answers
28
views
Pycharm Pro saving image from sciview as HTMl vs PNG gives different images
I'm using Pycharm pro and I'm trying to plot the filters and feature maps of CNN layers.
I always right-click the images and save them as png, but I tried to save the image as HTML, and I found the ...
0
votes
0
answers
94
views
Using Pytorch Sequential for reinforcement model without gym
I'm trying to play a game with AI, but I want to do it in real time. Because of that, I'm not using gym to create an environment.
I want to take a screenshot, preprocess it, then pass it through the ...
0
votes
0
answers
46
views
Why does one img2col implementation perform better than the other?
When I study convolutional layers, I implement im2col_2 by myself to handle the operation of convolution. im2col_1 is a different implementation which seems less intuitional. im2col_1 is pixel by ...
0
votes
0
answers
78
views
100% accuracy for multi_class classification
I am training a model for multi label classification task for each class I have multiple labels after running the test i got 100% for both classes
I used 150 000 images for training and validation and ...
-2
votes
2
answers
85
views
Why the even epochs are not giving appropriate results in binary classification problem
I wanted to do image classification using CNN and now I am getting abnormal results cause the even no of epochs are not working as expected even if i change the no of epochs
import os
import numpy as ...
0
votes
2
answers
164
views
How does the Conv2D method filter the featuremaps outputted by another Conv2D layer?
I am not understanding how the 20 filters of the second Conv2D layer filters the 10 feature maps outputted by the first Conv2D layer. Are each of the 20 filters filtering each of the 10 featuremaps (...
0
votes
1
answer
71
views
"RuntimeError: Numpy is not available" when using inverse_transform
I got this error on python 3.12.7:
Traceback (most recent call last):
File "/Users/hongviet/Library/Mobile Documents/com~apple~CloudDocs/Documents/DataAnlalysCoding/First Week/baitap1.py", ...
0
votes
1
answer
64
views
Loss and accuracy curves with spikes? [closed]
I'm currently working with CNN, LSTM, and BiLSTM as a hybrid algorithm, and these are the results I got for the accuracy and loss curves for the training and test sets. The issue is that I do not know ...
1
vote
0
answers
135
views
Unable to load resnet18 model from .pth file
I trained a ResNet18 model; and saved it to a .pth file.
When I try to load it I get this error, this continues for a couple more lines with the same pattern.
Error loading checkpoint: Error(s) in ...