Skip to content
Snippets Groups Projects
Commit d28248d8 authored by Tim O'Donnell's avatar Tim O'Donnell
Browse files

theano on python 2.7 fixes; pylint fixes

parent c07d80cf
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ import argparse ...@@ -8,7 +8,7 @@ import argparse
import mhcnames import mhcnames
import Bio.SeqIO import Bio.SeqIO # pylint: disable=import-error
def normalize(s, disallowed=["MIC", "HFE"]): def normalize(s, disallowed=["MIC", "HFE"]):
......
...@@ -13,7 +13,7 @@ import pandas ...@@ -13,7 +13,7 @@ import pandas
import mhcnames import mhcnames
import Bio.SeqIO import Bio.SeqIO # pylint: disable=import-error
def normalize_simple(s): def normalize_simple(s):
......
...@@ -1126,6 +1126,7 @@ class Class1NeuralNetwork(object): ...@@ -1126,6 +1126,7 @@ class Class1NeuralNetwork(object):
""" """
import keras import keras
import keras.backend as K
from keras.layers import Input from keras.layers import Input
from keras.models import Model from keras.models import Model
...@@ -1162,7 +1163,7 @@ class Class1NeuralNetwork(object): ...@@ -1162,7 +1163,7 @@ class Class1NeuralNetwork(object):
# Merging an ensemble of pan-allele architectures # Merging an ensemble of pan-allele architectures
network = networks[0] network = networks[0]
peptide_input = Input( peptide_input = Input(
shape=tuple(int(x) for x in network.inputs[0].shape[1:]), shape=tuple(int(x) for x in K.int_shape(network.inputs[0])[1:]),
dtype='float32', dtype='float32',
name='peptide') name='peptide')
allele_input = Input( allele_input = Input(
...@@ -1366,7 +1367,7 @@ class Class1NeuralNetwork(object): ...@@ -1366,7 +1367,7 @@ class Class1NeuralNetwork(object):
l is the allele sequence length, l is the allele sequence length,
m is the length of the vectors used to represent amino acids m is the length of the vectors used to represent amino acids
""" """
from keras.models import model_from_json from keras.models import clone_model
reshaped = allele_representations.reshape( reshaped = allele_representations.reshape(
(allele_representations.shape[0], -1)) (allele_representations.shape[0], -1))
original_model = self.network() original_model = self.network()
...@@ -1392,7 +1393,7 @@ class Class1NeuralNetwork(object): ...@@ -1392,7 +1393,7 @@ class Class1NeuralNetwork(object):
# Network surgery required. Make a new network with this layer's # Network surgery required. Make a new network with this layer's
# dimensions changed. Kind of a hack. # dimensions changed. Kind of a hack.
layer.input_dim = reshaped.shape[0] layer.input_dim = reshaped.shape[0]
new_model = model_from_json(original_model.to_json()) new_model = clone_model(original_model)
# copy weights for other layers over # copy weights for other layers over
for layer in new_model.layers: for layer in new_model.layers:
......
...@@ -270,7 +270,7 @@ def run(argv=sys.argv[1:]): ...@@ -270,7 +270,7 @@ def run(argv=sys.argv[1:]):
return main(args) return main(args)
except Exception as e: except Exception as e:
print(e) print(e)
import ipdb import ipdb # pylint: disable=import-error
ipdb.set_trace() ipdb.set_trace()
raise raise
else: else:
......
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