Question: Simple Siamese NN: Implement a simple TensorFlow - Keras neural model that has the following sequence of layers: An input layer that will accept the

Simple Siamese NN:
Implement a simple TensorFlow-Keras neural model that has the following sequence of layers:
An input layer that will accept the tf.idf of triplet data. The input of Siamese network is a triplet, consisting of anchor (i.e., the question), positive answer, negative answer.
3 hidden layers and a relu activation function. You need to determine the size of the hidden layers.
Implement a class that serves as a distance layer. It returns the squared Euclidean distance between anchor and positive answer, as well as that between anchor and negative answer.
Implement a function that prepares raw data in csv files into triplets. Note that it is important to keep the similar number of positive pairs and negative pairs. For example, if a question has 10 anwsers, then we at most can have 10 positive pairs and it is good to associate this question with 10~20 negative sentences.
Train the model with the training data and use the dev_test set to determine a good size of the hidden layer.
With the model that you have trained, implement a summariser that returns the n sentences with highest predicted score. Use the following function signature:
def nn_summariser(csvfile, questionids, n=1):
"""Return the IDs of the n sentences that have the highest predicted score.
The input questionids is a list of question ids.
The output is a list of lists of sentence ids
"""
Report the final results using the test set. Remember: use the test set to report the final results of the best system only.
YOU NEED TO ACKNOLEDGE THESE STEPS:
the NN model has the correct layers, the correct activation functions, and the correct loss function.
The code passes input to the model correctly.
The code returns the IDs of the n sentences that have the highest prediction score in the given question.
The notebook reports the F1 scores of the test sets and comments on the results.
For good coding and documentation in this task. In particular, the code and results must include evidence that shows your choice of best size of the hidden layer. The explanations must be clear and concise. To make this task less time-consuming, use n=1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!