Created
August 4, 2022 05:26
-
-
Save jeremytanjianle/30a69efd2af4323311a4f762020129ae to your computer and use it in GitHub Desktop.
config-implementation separation example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"model": { | |
"type": "model_with_gaussian", | |
"gaussian": { | |
"mean": 0.5, | |
"variance": 0.3 | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from allennlp.common import FromParams | |
class Gaussian(FromParams): | |
def __init__(self, mean: float, variance: float): | |
self.mean = mean | |
self.variance = variance | |
class ModelWithGaussian(FromParams): | |
def __init__(self, gaussian: Gaussian): | |
self.gaussian = gaussian | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment