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 TensorFlowKeras neural model that has the following sequence of layers:
An input layer that will accept the tfidf of triplet data. The input of Siamese network is a triplet, consisting of anchor ie the question positive answer, negative answer.
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 anwsers, then we at most can have positive pairs and it is good to associate this question with ~ negative sentences.
Train the model with the training data and use the devtest 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 nnsummarisercsvfile questionids, n:
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 F 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 timeconsuming, use n
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
