Skip to content
Snippets Groups Projects
Commit d4821f80 authored by Jeff Hammerbacher's avatar Jeff Hammerbacher
Browse files

Simple script that runs on Theano but not TF backend

parent 8f911c38
No related merge requests found
import numpy as np
import pandas as pd
import tensorflow as tf
from mhcflurry.dataset import Dataset
from mhcflurry.peptide_encoding import indices_to_hotshot_encoding
allele_list=['HLA-A0201', 'HLA-A2301', 'HLA-A2402', 'HLA-A1101']
file_to_explore="/root/.local/share/mhcflurry/2/class1_data/combined_human_class1_dataset.csv"
dataset = Dataset.from_csv(
filename=file_to_explore,
sep=",",
peptide_column_name="peptide")
df = dataset.to_dataframe()
df_reduced = df[df.allele.isin(allele_list)][['allele','affinity']].reset_index(drop=True)
df_kmers = dataset.kmer_index_encoding()
training_hotshot = indices_to_hotshot_encoding(df_kmers[0])
from keras.models import Sequential
from keras.layers import Dense, Activation
model = Sequential()
model.add(Dense(input_dim=9*21, output_dim=1))
model.add(Activation("sigmoid"))
model.compile(loss="mse", optimizer="rmsprop")
model.fit(training_hotshot, df_kmers[1], nb_epoch=5, batch_size=1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment