- We start by loading the necessary libraries and starting a graph session:
import os import random import string import numpy as np import matplotlib.pyplot as plt import tensorflow as tf sess = tf.Session()
- We now set the model parameters as follows:
batch_size = 200 n_batches = 300 max_address_len = 20 margin = 0.25 num_features = 50 dropout_keep_prob = 0.8
- Next, we create the Siamese RNN similarity model class as follows:
def snn(address1, address2, dropout_keep_prob, vocab_size, num_features, input_length): # Define the Siamese double RNN with a fully connected layer at the end def Siamese_nn(input_vector, num_hidden): cell_unit = tf.nn.rnn_cell.BasicLSTMCell # Forward direction cell lstm_forward_cell = cell_unit(num_hidden, ...