Template
迁移 lazy_config
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
from lazy_config.utils.config import LazyCall as L
|
||||
from projects.lazy_config_demo.model import SimpleModule
|
||||
|
||||
|
||||
MODEL = L(SimpleModule)(
|
||||
in_features=128,
|
||||
out_features=256,
|
||||
activation="sigmoid"
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
from lazy_config.utils.config import parse_args_and_configs, instantiate
|
||||
|
||||
|
||||
def main():
|
||||
cfg = parse_args_and_configs()
|
||||
model = instantiate(cfg.MODEL)
|
||||
print(model)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,14 @@
|
||||
class SimpleModule:
|
||||
|
||||
def __init__(self,
|
||||
in_features: int,
|
||||
out_features: int,
|
||||
activation: str = "relu"):
|
||||
self.in_features = in_features
|
||||
self.out_features = out_features
|
||||
self.activation = activation
|
||||
print(
|
||||
f"SimpleModule created: {in_features} -> {out_features}, activation: {activation}"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user