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

rename

parent 75a3278f
No related branches found
No related tags found
No related merge requests found
Showing
with 37 additions and 37 deletions
......@@ -1416,10 +1416,4 @@ class Class1NeuralNetwork(object):
original_model.fit = \
original_model.fit_generator = throw
session = K.get_session()
(weights_variable,) = layer.non_trainable_weights
session.run(weights_variable.initializer)
session.run(tf.assign(weights_variable, reshaped))
#
# Previously had this but was getting sporadic not initialized errors
# layer.set_weights([reshaped])
layer.set_weights([reshaped])
"""
Utilities used in MHCflurry unit tests.
"""
from . import Class1NeuralNetwork
def module_cleanup():
def cleanup():
"""
Clear tensorflow session and other process-wide resources.
"""
import keras.backend as K
Class1NeuralNetwork.clear_model_cache()
K.clear_session()
......@@ -14,8 +14,8 @@ from mhcflurry.downloads import get_path
os.environ["CUDA_VISIBLE_DEVICES"] = ""
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
def run_and_check(n_jobs=0, delete=True, additional_args=[]):
......
......@@ -8,8 +8,8 @@ from mhcflurry.downloads import get_path
from numpy.testing import assert_equal
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
ALLELE_TO_SEQUENCE = pandas.read_csv(
get_path(
......
......@@ -29,7 +29,7 @@ def setup():
def teardown():
global DOWNLOADED_PREDICTOR
DOWNLOADED_PREDICTOR = None
mhcflurry.testing_utils.module_cleanup()
mhcflurry.testing_utils.cleanup()
# To hunt down a weird warning we were seeing in pandas.
......
......@@ -13,8 +13,8 @@ from mhcflurry.class1_neural_network import Class1NeuralNetwork
from mhcflurry.downloads import get_path
from mhcflurry.common import random_peptides
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
def test_class1_neural_network_a0205_training_accuracy():
......
......@@ -11,8 +11,8 @@ from mhcflurry import Class1AffinityPredictor,Class1NeuralNetwork
from mhcflurry.allele_encoding import AlleleEncoding
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
HYPERPARAMETERS = {
......
......@@ -11,8 +11,8 @@ import keras.backend as K
from mhcflurry.custom_loss import CUSTOM_LOSSES
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
def evaluate_loss(loss, y_true, y_pred):
......
......@@ -5,7 +5,7 @@ from numpy.testing import assert_equal
from mhcflurry import Class1AffinityPredictor, Class1NeuralNetwork
from mhcflurry.testing_utils import module_cleanup
from mhcflurry.testing_utils import cleanup
DOWNLOADED_PREDICTOR = None
......@@ -19,7 +19,7 @@ def setup():
def teardown():
global DOWNLOADED_PREDICTOR
DOWNLOADED_PREDICTOR = None
module_cleanup()
cleanup()
def predict_and_check(
......
......@@ -12,8 +12,8 @@ logging.getLogger('tensorflow').disabled = True
from mhcflurry.class1_neural_network import Class1NeuralNetwork
from mhcflurry.common import random_peptides
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
def test_multi_output():
......
......@@ -5,7 +5,7 @@ from mhcflurry import Class1AffinityPredictor, Class1NeuralNetwork
from mhcflurry.common import random_peptides
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
from mhcflurry.testing_utils import cleanup
logging.getLogger('tensorflow').disabled = True
......@@ -23,7 +23,7 @@ def setup():
def teardown():
global PAN_ALLELE_PREDICTOR
PAN_ALLELE_PREDICTOR = None
module_cleanup()
cleanup()
def test_merge():
......
......@@ -6,8 +6,8 @@ from numpy.testing import assert_equal
from mhcflurry import predict_command
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
TEST_CSV = '''
Allele,Peptide,Experiment
......
......@@ -13,7 +13,7 @@ from nose.tools import eq_, assert_less, assert_greater, assert_almost_equal
from mhcflurry import Class1AffinityPredictor
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
from mhcflurry.testing_utils import cleanup
def data_path(name):
......@@ -41,7 +41,7 @@ def setup():
def teardown():
global PREDICTORS
PREDICTORS = None
module_cleanup()
cleanup()
def test_on_hpv(df=DF):
......
......@@ -15,7 +15,7 @@ from mhcflurry.encodable_sequences import EncodableSequences
from mhcflurry.downloads import get_path
from mhcflurry.common import random_peptides
from mhcflurry.testing_utils import module_cleanup
from mhcflurry.testing_utils import cleanup
PREDICTORS = None
......@@ -33,7 +33,7 @@ def setup():
def teardown():
global PREDICTORS
PREDICTORS = None
module_cleanup()
cleanup()
def test_correlation(
......
......@@ -18,7 +18,7 @@ from mhcflurry.encodable_sequences import EncodableSequences
from mhcflurry.common import random_peptides
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
from mhcflurry.testing_utils import cleanup
ALLELE_SPECIFIC_PREDICTOR = Class1AffinityPredictor.load(
get_path("models_class1", "models"))
......@@ -43,7 +43,7 @@ def setup():
def teardown():
global PREDICTORS
PREDICTORS = None
module_cleanup()
cleanup()
DEFAULT_NUM_PREDICTIONS = 10000
......
......@@ -14,8 +14,8 @@ from numpy.testing import assert_array_less, assert_equal
from mhcflurry import Class1AffinityPredictor
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
os.environ["CUDA_VISIBLE_DEVICES"] = ""
......
......@@ -15,8 +15,8 @@ from numpy.testing import assert_equal, assert_array_less
from mhcflurry import Class1AffinityPredictor,Class1NeuralNetwork
from mhcflurry.downloads import get_path
from mhcflurry.testing_utils import module_cleanup
teardown = module_cleanup
from mhcflurry.testing_utils import cleanup
teardown = cleanup
os.environ["CUDA_VISIBLE_DEVICES"] = ""
......
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