Questions tagged [siamese-network]

For questions relating to the ML model joint-embedding architecture known as a "Siamese network," aka "Twin network." [Siamese neural network at Wikipedia](https://en.wikipedia.org/wiki/Siamese_neural_network)

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

Simamese Network - Detect if x position of images are the same

Assuming I have an environment where an object can be at a position consisting of x,y with x=(0,3) and y=(0,3). I have images at all these positions and generate a dataset where all images are paired ...
abcdefghi999955's user avatar
0 votes
0 answers
27 views

Pytorch siamese model using lstm

I am building a siamese model using Lstm, I have trained and tested the model but I condn’t inference it on sigle sample Here’s the model class SiameseLstm(nn.Module): def __init__(self): ...
silver key's user avatar
0 votes
0 answers
32 views

Tensorflow Invalid Argument Error: "Input is empty" when creating dataset for Siamese CNN

I am creating a Siamese CNN that does facial recognition. To process the data, I am using the tf.data.Dataset libraries. However, when I try to use my dataset as a numpy iterator, I get this error: ...
Danielle Croft's user avatar
0 votes
0 answers
17 views

Is it possible to work in Appen just using Android? because at the moment we don't have a laptop but we really want to join the project from Appen

Can the Appen project be done using only Android? I really hope I can because I don't have a laptop yet and really want to join the APPEN project Please help with an explanation regarding working on ...
hari wibowo's user avatar
0 votes
0 answers
29 views

Tensorflow Incompatible shapes: [16,48] vs. [0]

I have the following code portion for a siamese network def build_sequential_model(input_shape, embedding_dim=16): model = Sequential() model.add(Input(shape=(input_shape,))) model.add(...
OUTATIME's user avatar
0 votes
1 answer
19 views

How to build a CNN model with keras to classify images based on two views and batch dataset as training dataset?

I want to create a CNN model with keras to classify images based on two views. Training data are given as batch dataset. Here below, you can find the code I have used but it does not work correctly: ...
Yassine's user avatar
2 votes
1 answer
73 views

TensorFlow Custom Loss Function Error: Node: 'gradient_tape/contrastive_loss/mul/BroadcastGradientArgs' Incompatible shapes [0,1] vs. [32,1]

I'm working on a Siamese network using TensorFlow and Keras. As the data is huge I am also trying to use the generator for batch loading. I have a custom contrastive loss function that I'm using for ...
Sahil Sinha's user avatar
1 vote
0 answers
47 views

Face recognition with siamese network and triplet loss does not learning useful patterns

i am new to this field and i am trying to make an alogrithm using triplet loss and siamese network to make a face recognition and the problem is that the loss value does not decrease lower than the ...
kareem said's user avatar
0 votes
0 answers
19 views

Siamese Network for Name Similarity using Hybrid Glove & FastText Embeddings Isn't Learning

Hello StackOverflow community, I am currently working on a project where I aim to build a Siamese network for determining the similarity between names. For my word embeddings, I'm using a hybrid ...
Itai Dagan's user avatar
0 votes
0 answers
19 views

.backward() taking much longer when training a Siamese network

I'm training a Siamese network for image classification and comparing to a baseline that didn't use a Siamese architecture. When not using the Siamese architecture each epoch takes around 17 minutes, ...
Farhan Omi's user avatar
0 votes
1 answer
70 views

Siamese model does not converge (Pytorch)

I spent one week trying to solve problem with siamese pytorch model. I will explain all in details. My model takes two anime faces images as an input, model should say if they are similar. Here is ...
Maximax67's user avatar
1 vote
0 answers
252 views

How to compare images using AI?

I have an issue, where I need to compare shapes that appear in images. The images might show the same thing, but their content might be twisted, turned, ... a conventional algorithm would therefore ...
Fauna Muirgen's user avatar
0 votes
0 answers
63 views

Siamese Network in TensorFlow employing Triplet Loss

Thank you for taking the time! I am constructing a siamese network using TensorFlow which uses triplet loss. My inputs are of shape (100,100,1) and I have made a CNN embed_model to so that the output ...
Adveat Prasad Karnik's user avatar
0 votes
0 answers
51 views

Nan values in training epochs of siamese network

the loss function is giving output as nan while training the model. I wanted to compare two pics of the same person. ive used an online dataset for training facial data while predicting its gives this ...
KARTIKYA ARORA's user avatar
1 vote
0 answers
104 views

Triplet Loss with Cross Entropy Loss?

I'm trying to learn how to use a TripletLoss in a Siamese Network. My goal is to build a classification siamese model, so I suppose I need both a Triplet Loss to minimize distances and a Cross Entropy ...
ChiG's user avatar
  • 19
0 votes
0 answers
14 views

Need help debugging Pytorch implementation of a Siamese Neural Network

I put together the following Pytorch implementation a simple Siamese neural network with a binary classification dataset of two concentric rings in 2D, but my training loss seems to oscillate between ...
user21961840's user avatar
0 votes
0 answers
25 views

Feeding data into a Siamese Network

For my project I have decided to use a CNN with triplet loss for feature embedding. I have preprocessed my data to create 72xframes windows, I have defined functions that get me batches thereof with ...
Tria Ufo's user avatar
0 votes
0 answers
35 views

Why is my accuracy a constant number when training my siamese model?

I am training a siamese model but my accuracy sometimes fall to a constant number. There are times where it trains fine, it'll give me an accuracy above 0.9 and it's not a constant number with every ...
Chewji's user avatar
  • 1
0 votes
0 answers
16 views

find the same object from two images which contain two crowds of such similar objects

this is more like a brainstorming topic, any suggestion will be welcome. Suppose there are two drone flying over a sea area. There is a big group of ships (following picture 1). each drone will ...
user9606634's user avatar
0 votes
1 answer
140 views

Loss function for a Siamese neural network

I'm trying to train Siamese neural networks for face recognition. Many resources use this function as a loss function: def contrastive_loss(y_true, y_pred): margin = 1 return K.mean(y_true * K....
Inki's user avatar
  • 3
0 votes
0 answers
35 views

Keras | Two inputs as a pair of a class | Siamese approach

I'm using pre-trained EficcientNetb3 that accepts one input image. I'm working on an image classification problem and I need to work with pairs instead of working with each image. My task is to edit ...
Arnold's user avatar
  • 1
0 votes
0 answers
68 views

Implementing Siamese Network with Triplet Loss

I'm trying ti implement saimese network using triplet loss function. The triplet loss function is taking two argument, 3rd one is set to some value so i don't need to care about that. But when ever i ...
TalkingParrot's user avatar
0 votes
0 answers
37 views

Improving Performance of One Shot Learning Architecture for 1D Arrays in TensorFlow

The objective is to compare two 1D array signals. The approach involves converting the input signals into their corresponding encodings, followed by a distance calculation. The anticipated output is a ...
Karan Owalekar's user avatar
0 votes
0 answers
40 views

Implement Siamese network for classification task ( ValueError: Layer "model_27" expects 2 input(s), but it received 1 input tensors)

I want to use Siamese network for classification task on CIFAR10 data set. The training data contains 5K pairs of images from different classes, the validation data contains 10K single images. My ...
Hadar V's user avatar
0 votes
0 answers
78 views

How to prepare data for siamese network and create image-pairs?

I have some images. I want to image similarity estimation using a Siamese Network with a contrastive loss. So I prepare the data structure like this: │ ├── data/ │ ├── pairs1/ │ │ ├── image_01....
Hale's user avatar
  • 41
0 votes
0 answers
54 views

Gradient accumulation for Siamese network

I am implementing gradient accumulation in PyTorch for the training of a Siamese network where one of the inputs is constant throughout the accumulated batches. Currently, my training loop looks ...
Sebastian Thomas's user avatar
1 vote
0 answers
130 views

Why loss is not decreasing in a Siamese BERT-Network training (Entity matching task)

I'm trying to finetune a model for an entity matching task (kind of a sentence similarity task). The idea is that if I give as input two sentences the model should output if they represent the same ...
pushz's user avatar
  • 21
0 votes
1 answer
84 views

Siamese Network in Tensorflow -- Changing Sigmoid Activiation Cutoffs

I've built the siamese network from the PyImageSearch.com tutorial here: https://pyimagesearch.com/2020/11/30/siamese-networks-with-keras-tensorflow-and-deep-learning/ I'm augmenting the CNN to detect ...
mjasilver's user avatar
0 votes
0 answers
75 views

How to combine multiple .h5 files trained from a Siamese neural network

picture of all the plant dataset h5 files in one directory I have multiple .h5 files with plant datasets trained from a Siamese model. i m trying to combine all into one h5 file for evaluation. i can ...
unknown name's user avatar
0 votes
0 answers
119 views

When training the Siamese network, the model accuracy does not change

I want to use the twin RNN network for time series classification, using contrastive loss as the loss function, but no matter how to adjust the margin parameter, the accuracy of the model is always 50%...
msskx's user avatar
  • 27
0 votes
0 answers
282 views

Contrastive loss in Siamese Network in Keras

I have been playing around with the contrastive loss of the Siamese network in Keras. In the original paper, the similar pair should be denoted as 0, and the dissimilar pair should be assigned as 1. ...
Richard Tony's user avatar
2 votes
1 answer
177 views

I want make positive image and label pairs but I take this error IndexError: list index out of range

I use the face dataset for the siamese network. In this dataset, we have 1000 unique labels(labels are names of the folders), and in each folder, we have 20 images all images in this dataset are 20000....
Erfan Sharifi's user avatar
0 votes
0 answers
35 views

Siamese Neural Network , RuntimeError: size mismatch, m1: [20 x 5], m2: [10 x 5] at ..\aten\src\TH/generic/THTensorMath.cpp:41

I am trying to build a Siamese Neural Network with following code class MySiameseNet(nn.Module): def __init__(self): super(MySiameseNet,self).__init__() self.nn = nn.Sequential( ...
Naseer's user avatar
  • 4,101
1 vote
0 answers
90 views

Shape similarity network (that it is not SSIM)

There are many CNNs for object classification and shapes drawing (e.g., square, heart, curved line etc) classification is even simpler. However, I haven't found yet a robust method for shape quality ...
Roi Yozevitch's user avatar
0 votes
1 answer
64 views

how to use keras demo code siamese_contrastive.py to use a custom dataset?

I am following this example Image similarity estimation using a Siamese Network with a contrastive loss. The given code snippet reads directly from keras.datasets.mnist.load_data(). I am trying to ...
Exploring's user avatar
  • 2,695
1 vote
0 answers
575 views

Model cannot be saved because the forward pass of the model is not defined

I am trying to save a model after training. The code trains the model and then I am trying to save the model. But at the time of saving the model, I get the following error from the model.save API ...
Exploring's user avatar
  • 2,695
0 votes
1 answer
341 views

How do I create support set, positive and negative pairs for siamese network

I have a siamese that takes a pair of inputs. I want to create positive, negative and support sets to train the network that I mentioned here. Positive pair: images from same view (or maybe different ...
Borhan Uddin's user avatar
1 vote
0 answers
126 views

LSTM model has constant loss during whole training

Siamese Model implementation can be found below: class ClassifierSiameseLSTM(nn.Module): def __init__(self, num_sensors=2, hidden_units=16): super().__init__() self.num_sensors = ...
Zafer Yıldız's user avatar
0 votes
1 answer
641 views

How to create image pairs for Siamese network using keras imagedatagenerator

I want to create the positive and negative image pairs to train a Siamese network. My siamese network looks like following def ResNet_model(): baseModel = ResNet50(weights="imagenet"...
Borhan Uddin's user avatar
4 votes
1 answer
643 views

Siamese Network for binary classification with pre-encoded inputs

I want to train a Siamese Network to compare vectors for similarity. My dataset consist of pairs of vectors and a target column with "1" if they are the same and "0" otherwise (...
benhid's user avatar
  • 134
1 vote
0 answers
205 views

Change detection using Siamese network

I have been trying to find a good way to do a change detection with some images, I have found the following SNUNet paper witht heir github https://github.com/likyoo/Siam-NestedUNet, but when trying to ...
secret's user avatar
  • 505
6 votes
1 answer
783 views

Evaluating (model.evaluate) with a triplet loss Siamese neural network model - tensorflow

I have trained a Siamese neural network that uses triplet loss. It was a pain, but I think I managed to do it. However, I am struggling to understand how to make evaluations with this model. The SNN: ...
maxipod's user avatar
  • 79
0 votes
1 answer
588 views

How does a Siamese neural network calculate distance between outputs with triplet loss?

I am using a Siamese neural network to learn similarity between text. Here is a SNN network I created for this task: it feeds two inputs into a Bidirectional LSTM, which shares/updates weights, and ...
yama's user avatar
  • 17
0 votes
1 answer
403 views

How contrastive loss work intuitively in siamese network

I am having issue in getting clear concept of contrastive loss used in siamese network. Here is pytorch formula torch.mean((1-label) * torch.pow(euclidean_distance, 2) + ...
Talha Anwar's user avatar
  • 2,771
0 votes
1 answer
733 views

Tensorflow ValueError: Shapes (64, 1) and (1, 1) are incompatible

I'm trying to build a Siamese Neural Network to analyze the MNIST dataset, however when trying to fit the model to the dataset I encounter this problem according to which I have training data and ...
Alex Aramyan's user avatar
0 votes
1 answer
179 views

Trying to train a model on Jupiter and Google Colab. getting errors when trying to implement gradient calculations

The errors I get are: ZipFile requires mode 'r', 'w', 'x', or 'a' or ZipFile.__init__() got multiple values for argument 'mode' or TypeError: 'ZipFile' object is not callable My Code: @tf.function def ...
KOR's user avatar
  • 3
2 votes
0 answers
554 views

Could someone explain me what's behind the FaceNet Paper ? (one-shot learning, siamese network and triplet loss)

I'm struggling since about 3 weeks on my One-Shot learning project. I'm trying to unlock my computer with my face. Unfortunately, I'm far from this task. First, I wanted to understand well the ...
ThOpaque's user avatar
0 votes
1 answer
59 views

How to build a character-level siamise network using Keras

I am trying to build a Siamese neural network on characters-level using Keras, to learn if two names are similars or not. So my two inputs X1 and X2 are a 3-D matrices: X[number_of_cases, ...
tammuz's user avatar
  • 407
0 votes
1 answer
2k views

How to train large datasets in Colab free

I have to train 70,000 images for my face verification project on google colab free. First, it gets stuck on 1st epoch and then even if it starts training, after sometime it throws out of RAM error. ...
binary_beast's user avatar
-2 votes
1 answer
124 views

print(target.size()s_history) SyntaxError: invalid syntax

File "/tmp/ipykernel_15300/319840370.py", line 18 print(target.size()s_history) ^ SyntaxError: invalid syntax
Edo Gen's user avatar