All Questions
Tagged with tf.keras conv-neural-network
122
questions
16
votes
6
answers
49k
views
InvalidArgumentError: required broadcastable shapes at loc(unknown)
Background
I am totally new to Python and to machine learning. I just tried to set up a UNet from code I found on the internet and wanted to adapt it to the case I'm working on bit for bit. When ...
8
votes
2
answers
4k
views
What is the difference between conv1d with kernel_size=1 and dense layer?
I am building a CNN with Conv1D layers, and it trains pretty well. I'm now looking into how to reduce the number of features before feeding it into a Dense layer at the end of the model, so I've been ...
8
votes
1
answer
744
views
TF2.1: SegNet model architecture problem. Bug with metric calculation, keeps constant and converge to determined value
I'm building a custom model (SegNet) in Tensorflow 2.1.0.
The first problem I'm facing is the reutilization of the indices of the max pooling operation needed as described in the paper.
Basically, ...
7
votes
2
answers
3k
views
Weighting samples in multiclass image segmentation using keras
I am using a Unet based model to perform image segmentation on a biomedical image. Each image is 224x224 and I have four classes including the background class. Each mask is sized as (224x224x4) and ...
5
votes
1
answer
6k
views
What is the numpy equivalent of TensorFlow Xavier initializer for CNN?
I would like to re-create the Xavier initialization in NumPy (using basic functions) in the same way that TensorFlow2 does for CNN.
Here is how I learned to do Xavier initialization in NumPy:
# ...
5
votes
1
answer
10k
views
ValueError: A `Concatenate` layer should be called on a list of at least 2 inputs
I'm trying to use a sigmoid to join the output of two models with different embedding matrix. but I keep getting the error at the concatenate line. I have tried other suggestions from similar ...
4
votes
1
answer
1k
views
How to construct a sobel filter for kernel initialization in input layer for images of size 128x128x3?
This is my code for sobel filter:
def init_f(shape, dtype=None):
sobel_x = tf.constant([[-5, -4, 0, 4, 5], [-8, -10, 0, 10, 8], [-10, -20, 0, 20, 10], [-8, -10, 0, 10, 8], [-5, -4, 0, 4, 5]])
...
4
votes
1
answer
2k
views
ValueError: Operands could not be broadcast together with shapes (54, 54, 128) (54, 54, 64)
I wrote a ResNet block with three convolutional layers:
def res_net_block(input_data, filters, kernel_size):
kernel_middle = kernel_size + 2
filters_last_layer = filters * 2
x = Conv2D(filters, ...
3
votes
3
answers
19k
views
Unknown metric function: Please ensure this object is passed to the `custom_objects` argument
I have trained a model with keras using transfer learning. since the whole code is almost big i only bring important parts.
For learning rate I cloned from github some code to be able to use cyclic ...
3
votes
2
answers
8k
views
UnknownError: Failed to get convolution algorithm
Complete Error :
UnknownError: Failed to get convolution algorithm. This is probably
because cuDNN failed to initialize, so try looking to see if a warning
log message was printed above. [Op:...
3
votes
1
answer
1k
views
why does tensorboard give this error: InvalidArgumentError: Nan in summary histogram for
I built the model to classification using 1D convolution layers using tf.Keras .this works well if I remove the tensorboard.As I'm a beginner,I can't figure it out what the problem is.
Please help
%...
3
votes
1
answer
697
views
In the convolution layer (Conv1D and Conv2D) in Tensorflow, when set padding='same', which side is padded with 0?
In tf.keras.layers.Conv1D and Conv2D, the argument padding has the 'same' option. I just want to know e.g., Conv1D, which side (the start or the end) is padded with 0 if the kernel_size=2 and stride=1....
3
votes
1
answer
486
views
KerasLayer vs tf.keras.applications performances
I've trained some networks with ResNetV2 50 ( https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/4 ) and it work very well for my datasets.
Then I tried tf.keras.applications.ResNet50 and ...
3
votes
0
answers
858
views
Tensorflow 2.0/Keras: Using a SparseTensor as the input to a Conv2D layer
I'm trying to build a network using the Keras library of Tensorflow 2.0 which
Takes a SparseTensoras input, and
Uses Conv2D as its first hidden layer.
My motivation behind using this architecture is ...
2
votes
2
answers
8k
views
Good performance with Accuracy but not with Dice loss in Image Segmentation
I'm doing image segmentation with U-Net like architecture on Tensorflow w/Keras but I'm new in Deep Learning.
I've got this dataset with the following set shapes:
Train : X : (175250, 30, 30, 6) Y: (...
2
votes
1
answer
2k
views
How should the data folder be to take input as (x-train, y-train), (x-test, y-test) in a cnn model
I am new to machine learning and deep learning. I have tried a multi-class classification model using CNN algorithm. I first tried it using the CIFAR-10 data set which is provided by the keras.
In ...
2
votes
1
answer
3k
views
ValueError:Layer conv1d was called with an input that isn't a symbolic tensor.All inputs to the layer should be tensors
I built this model and it was working fine.
###Building the Model.
input_layer= Embedding(num_words, 300, input_length=35, weights=[embedding_matrix],trainable=True)
conv_blocks = []
filter_sizes = ...
2
votes
1
answer
218
views
About input_shape in keras.layers from tensorflow
I am a beginner for tensorflow. I had just tried to fit a simple LeNet-5 for mnist data.
My training and test data are first in Numpy format. i.e., (60000, 28, 28). Then I set my model as below.
...
2
votes
1
answer
1k
views
TypeError: 'Tensor' object cannot be interpreted as an integer when using tf.map_fn()
I am trying to construct label-dependent convolutional filters in keras/tensorflow. Therefore, the convolutional filter(s) depend on each example in the batch.
# function used for tf.map_fn
def ...
2
votes
1
answer
1k
views
How to load my tensorflow model with ModelCheckpoint callbacks?
I have trained a model and save the weights using ModelCheckpoint:
checkpoint_callback = ModelCheckpoint(
filepath = checkpoint_prefix,
save_weights_only = True,
save_freq = 'epoch')
...
2
votes
1
answer
288
views
object has no attribute '_compile_metrics', even with metric = ['accuracy']
I created this structure with the ResNet50 base model and a couple other layers, then compiled it in the end which I made sure I included this small code...
metrics=['accuracy']
so I should not be ...
2
votes
1
answer
387
views
Keras - One Class CNN - Two inputs one at each step
I'm trying to train a One Class CNN but want only train on one class. So to solve the problem of not having a negative class instead of add random images to a 'no-class' label I want to train with ...
1
vote
1
answer
2k
views
Why is VGG16 giving lesser no. of total parameters?
from tensorflow.keras.applications import VGG16
pre_trained_model = VGG16(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
model = Sequential()
model.add(pre_trained_model)
model....
1
vote
1
answer
86
views
why keras wont train on my entire image set
I am training a convolutional model in keras.
The size of my training data is
(60000, 28, 28, 1)
I build a simple model here
model = Sequential()
model.add(
Conv2D(
filters=32,
...
1
vote
1
answer
284
views
'NoneType' object has no attribute '_inbound_nodes' error
I have to take the output of last conv layer of EfficientNet and then calculate H = wT*x+b. My w is [49,49]. After that I have to apply softmax on H and then do elementwise multiplication Xì = Hi*Xi.
...
1
vote
1
answer
2k
views
Validation accuracy not improving after reaching 90%
I have around 14,000 images for face detection binary classification task. Around 12,000 images are used for training and 2,200 for validation. My CNN architecture is as follows -
regularizer = tf....
1
vote
1
answer
81
views
Extracting Transfer learning output from CNN Keras
How to take the intermediate Transfer learning output. ? Eg:
from keras.models import Sequential
from keras.layers import Dense
# ... Other Imports..
from tensorflow.keras.applications.resnet50 ...
1
vote
2
answers
155
views
Tensorflow Keras Estimator fails on regression task while underlying model works
I use a convolutional neural network for a regression task (i.e. the final layer of the network has one neuron with linear activation) and this works fine (enough). When I try to use the exact same ...
1
vote
1
answer
706
views
"unknown node" error in Keras convolutional neural network
I have the following (2D) convolutional neural network in Keras for image classification with binary labels:
model = keras.Sequential()
model.add(Conv2D(32, kernel_size=5, activation='relu', ...
1
vote
0
answers
76
views
How can I create a learnable parameter or weight vector whose values are either 1 or -1
I need to build a neural network which is known as learnable parameter or a weight vector. In that way, only one vector will be generated and multiplied with the data. I have created that as following:...
1
vote
0
answers
137
views
How to Determine the Output Shape of a Conv2DTranspose of an AutoEncoder
I am building an autoencoder for learning 28 ultrasound time signals of shape [262144,2] i.e. 262144 pairs of time and voltage points concatenated to form a [262144x2] tensor as input data to a ...
1
vote
0
answers
58
views
editing output of a Keras layer
I have a Convolutional Neural Network in the shape of the simple LeNet-5. I am using the modified NIST data set as my inputs
Here's my question: I want to take the output of conv2d and divide ...
1
vote
2
answers
149
views
Neural network only predicts one class
my model only predicts one class from binary class. The model takes a video input using Keras Video Frame Generator and get 350 frames for each video. The model must take an input sequences of 350 ...
1
vote
0
answers
94
views
Same accuracy in all epochs in GoogleNet neural network
outputI am getting same accuracy in all epochs of GoogleNet, this should not be the case, the network should learn in each epoch and therefore accuracy should vary in each epoch.
Please look at my ...
1
vote
2
answers
1k
views
How do I reshape input layer for Conv1D in Keras?
I looked at various responses already but I dont understand why I am constantly getting (10, 5).
Why is it asking for a shape of (10,5)? Where is it even getting that number from?
I am under the ...
1
vote
2
answers
4k
views
history=model.fit_generator() Why is keras history empty?{}
I can't obtain history from model.fit_generator()
net_history=densenet_model.fit_generator(
generator=train_loader,
steps_per_epoch=len(train_dataset),
max_queue_size=500,
workers=1,
...
1
vote
1
answer
58
views
Keras model.predict() throwing ValueError
X and Y is of shape (89362, 5) and (89362,) repectively.
x_train, x_test, y_train, y_test = train_test_split(X, Y,
test_size = 0.3,
...
1
vote
2
answers
724
views
How to modify elements of a Keras Tensor object
I am building a Convolution Neural Network in Keras that receives batch of images with dimensions (None, 256, 256, 1) and the output would be batches with size (None, 256, 256, 3). Now after the final ...
1
vote
1
answer
538
views
What does keras.layers.concatenate do
I came across the following code and was wondering what exactly does keras.layers.concatenate do in this case.
Best Guess:
In fire_module(), y learns based on every pixel(kernel_size=1)
y1 learns ...
1
vote
1
answer
297
views
Keras training works on binary_crossentropy but not categorcial_crossentropy
This question is NOT a duplicate of the following questions.
Moved to Tensorflow 2.0, training now hangs after third step
Keras sees my GPU but doesn't use it when training a neural network
...
1
vote
0
answers
269
views
Incompatible shapes error when using multi_gpu_model on fit_generator
We are trying use multi_gpu_model to be able to train on 4 gpus, but we receive an incompatible shapes error. The program works without issue if the multi_gpu_model line is removed.
We tried making ...
1
vote
0
answers
2k
views
StreamExecutor device (0): <undefined>, <undefined>
I am extremely new to TensorFlow and I am trying to run this keras implementation of Class Activation Map on ResNet50. But I get the below error and I couldn't get the output. I don't understand the ...
0
votes
1
answer
2k
views
Input 0 incompatible with layer inception_v3 expected shape=(None, 299, 299, 3), found shape=(1, 229, 229, 3)
How to convert shape=(1, 299, 299, 3) to expected shape=(None, 299, 299, 3) to feed into trained inception v3 model.
NOTE: THE SAME QUESTION HAVE BEEN ASKED BEFORE BUT THE ANSWER ISN'T CLEAR ENOUGH.
...
0
votes
1
answer
818
views
How to work with 3D images in Keras ImageDataGenerator flow_from_dataframe
I want to estimate numerical values using 3D images, so i want to combine 3D CNN with Regression.
I am working on 3D image data stored as .raw files with shape (200,200,200). When I try to use Keras ...
0
votes
2
answers
521
views
Predicting single image using Tensorflow not being accurate
I'm trying to build a CNN model in order to classify an image, but whenever the training is done and I try to feed it a single image (from the training dataset) it misclassifies this image always.
...
0
votes
1
answer
1k
views
How to get class activation map for multi output model?
I'm trying to visualize Gradcam Activation maps of each output of a CNN model, with multiple outputs. The problem is how to implement the 'loss function'? I'm referring to this code.https://github.com/...
0
votes
1
answer
1k
views
How to combine independent CNN and LSTM networks
I'm currently working with timeseries forecasts using tensorflow and keras. I built an CNN which performs quite good and a basic LSTM with shows also quite good results. Now I was thinking to combine ...
0
votes
1
answer
43
views
image augmentations using tensorflow
i have a question about augmentations...when we use ImageDataGenerator with certain changes like zooming, shifting, and flipping for training.... does this mean the model won't ever see the original (...
0
votes
1
answer
93
views
Terrible accuracy in keras CNN
I am a beginner to deep learning and I am trying to create a model of handwritten words classification, I created the dataset and it contains 71 different classes with 1000 image of each class.
The ...
0
votes
1
answer
227
views
Is validation curve slight greater or lower in CNN models good?
Can you tell me which one among the two is a good validation vs train plot?
Both of them are trained with same keras sequential layers, but the second one is trained using more number of samples, i.e. ...