diff --git a/mhcflurry/class1_affinity_predictor.py b/mhcflurry/class1_affinity_predictor.py index f1251282814fdb23870948e329bf3cd292a9a973..7ba6a43bc968de29ba4ce83d6c4722f83d3f3218 100644 --- a/mhcflurry/class1_affinity_predictor.py +++ b/mhcflurry/class1_affinity_predictor.py @@ -153,6 +153,9 @@ class Class1AffinityPredictor(object): @property def num_networks(self): + """ + Total number of neural networks (models) + """ return self.manifest_df.shape[0] diff --git a/mhcflurry/class1_neural_network.py b/mhcflurry/class1_neural_network.py index 07ee5a307a3c0ef1263985bf023381bce26c9b90..eafbbf96398e58eb0028a8bfaadab62835377a67 100644 --- a/mhcflurry/class1_neural_network.py +++ b/mhcflurry/class1_neural_network.py @@ -48,15 +48,27 @@ class Class1NeuralNetwork(object): } ], ) + """ + Hyperparameters (and their default values) that affect the neural network + architecture. + """ compile_hyperparameter_defaults = HyperparameterDefaults( loss="mse", optimizer="rmsprop", ) + """ + Loss and optimizer hyperparameters. Any values supported by keras may be + used. + """ input_encoding_hyperparameter_defaults = HyperparameterDefaults( left_edge=4, right_edge=4) + """ + Number of amino acid residues that are given fixed positions on the each + side in the variable length encoding. + """ fit_hyperparameter_defaults = HyperparameterDefaults( max_epochs=500, @@ -70,6 +82,9 @@ class Class1NeuralNetwork(object): random_negative_affinity_max=50000.0, random_negative_match_distribution=True, random_negative_distribution_smoothing=0.0) + """ + Hyperparameters for neural network training. + """ early_stopping_hyperparameter_defaults = HyperparameterDefaults( patience=10, @@ -78,12 +93,18 @@ class Class1NeuralNetwork(object): verbose=1, # currently unused mode='auto' # currently unused ) + """ + Hyperparameters for early stopping. + """ hyperparameter_defaults = network_hyperparameter_defaults.extend( compile_hyperparameter_defaults).extend( input_encoding_hyperparameter_defaults).extend( fit_hyperparameter_defaults).extend( early_stopping_hyperparameter_defaults) + """ + Combined set of all supported hyperparameters and their default values. + """ def __init__(self, **hyperparameters): self.hyperparameters = self.hyperparameter_defaults.with_defaults( @@ -97,9 +118,11 @@ class Class1NeuralNetwork(object): self.fit_seconds = None self.fit_num_points = None - # Process-wide keras model cache. - # architecture JSON string -> (Keras model, existing network weights) KERAS_MODELS_CACHE = {} + """ + Process-wide keras model cache, a map from: architecture JSON string to + (Keras model, existing network weights) + """ @classmethod def borrow_cached_network(klass, network_json, network_weights): diff --git a/mhcflurry/common.py b/mhcflurry/common.py index f87d235d999e124aa036c80b95301005b167f7be..060dc4f66d20b23f639d175b0f49593340ceec2e 100644 --- a/mhcflurry/common.py +++ b/mhcflurry/common.py @@ -71,6 +71,14 @@ def freeze_object(o): def configure_logging(verbose=False): + """ + Configure logging module using defaults. + + Parameters + ---------- + verbose : boolean + If true, output will be at level DEBUG, otherwise, INFO. + """ level = logging.DEBUG if verbose else logging.INFO logging.basicConfig( format="%(asctime)s.%(msecs)d %(levelname)s %(module)s - %(funcName)s:" diff --git a/mhcflurry/downloads.py b/mhcflurry/downloads.py index 81ef467e51e2670096a7830e2b67a9f24a9a23df..21800feba7d75582432c8ffc6fac9db8bf48bc5f 100644 --- a/mhcflurry/downloads.py +++ b/mhcflurry/downloads.py @@ -69,12 +69,13 @@ def get_current_release_downloads(): Return a dict of all available downloads in the current release. The dict keys are the names of the downloads. The values are a dict - with entries: - downloaded : bool - Whether the download is currently available locally + with two entries: - metadata : dict - Info about the download from downloads.yml such as URL + downloaded : bool + Whether the download is currently available locally + + metadata : dict + Info about the download from downloads.yml such as URL """ downloads = ( get_downloads_metadata()