forked from IDSIA/sacred
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathingredient.py
executable file
·61 lines (40 loc) · 1.2 KB
/
ingredient.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# coding=utf-8
from sacred import Ingredient, Experiment
# ================== Dataset Ingredient =======================================
# could be in a separate file
data_ingredient = Ingredient("dataset")
@data_ingredient.config
def cfg1():
filename = "my_dataset.npy" # dataset filename
normalize = True # normalize dataset
@data_ingredient.capture
def load_data(filename, normalize):
print("loading dataset from '{}'".format(filename))
if normalize:
print("normalizing dataset")
return 1
return 42
@data_ingredient.command
def stats(filename, foo=12):
print('Statistics for dataset "{}":'.format(filename))
print("mean = 42.23")
print("foo=", foo)
# ================== Experiment ===============================================
@data_ingredient.config
def cfg2():
filename = "foo.npy"
# add the Ingredient while creating the experiment
ex = Experiment("my_experiment", ingredients=[data_ingredient])
@ex.config
def cfg3():
a = 12
b = 42
@ex.named_config
def fbb():
a = 22
dataset = {"filename": "AwwwJiss.py"}
@ex.automain
def run():
data = load_data() # just use the function
print("data={}".format(data))