Question: YOU MUST USE THESE FUNCTIONS PLEASE 1 ) A function make _ tfm _ model ( T ) which takes a parameter T ( a

YOU MUST USE THESE FUNCTIONS PLEASE 1)A function make_tfm_model(T) which takes a parameter T (a string with value either tcr or
antigen and returns a PyTorch object (untrained, subclass of nn.Module) that implements the
transformer model for the corresponding tcr/antigen sequences.
2. A function make_predict_model(M_antigen, M_tcr) which takes two parameters: M_tcr is the
TCR transformer model and M_antigen is the antigen transformer model, and return the full
model that makes the prediction on the TCR-antigen interaction.
3. A function pretrain_tfm_model(M, D, n_epochs) which takes a transformer model M and a
training data set D (a list of sequences) and pretrain the model M as specified above for
n_epochs. At the end of each epoch, print out the average loss during that epoch.
4. A function train_model(M, L_antigen, L_tcr, Interaction, n_epochs) which trains the full
prediction model M passed to it for n_epochs using the following data: L_antigen, a list of
antigen sequences, L_tcr, a list of TCR sequences, and Interaction, list of the numbers (0/1)
indicating interaction or not. (Clearly these three lists are of the same length.) At the end of each
epoch, print out the average loss during that epoch.
5. A function load_trained_model() which should download your trained model saved somewhere
online and load it from the downloaded file. The function then returns the model. Do not train the
model from scratch in this function. Same as HW1/2, you should not upload the model file to
moodle. Instead, you should share it in your google drive (or other online storage which can be
shared by link).
6. A function predict(M, L_antigen, L_tcr) which takes a full prediction model M and L_antigen,
a list of antigen sequences, L_tcr, a list of TCR sequences. (Again the two lists are of the same
length.) For each corresponding pair of sequences in L_antigen and L_tcr, the function should
use the model to make a prediction on their interaction. Return a list of the prediction results
(0/1).
7. In a comment section at the beginning of the .py file, report the result from your 3-fold cross
validations. For each fold/run, report the accuracy of the trained model on the left-aside test data.
Also report the average of the 3-folds (total 4 numbers/measures for a model). Report the
measures for both the model with and the one without pretraining. Show the performance gain by
pretraining and discuss briefly whether it meets your expectation.
YOU MUST USE THESE FUNCTIONS PLEASE 1 ) A

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 Programming Questions!