File size: 3,332 Bytes
b84549f |
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
import os
from peewee import CharField, FloatField, ForeignKeyField, IntegerField, Model
from playhouse.sqlite_ext import JSONField, SqliteExtDatabase
from nni.nas.benchmarks.utils import json_dumps
from nni.nas.benchmarks.constants import DATABASE_DIR
db = SqliteExtDatabase(os.path.join(DATABASE_DIR, 'nlp.db'), autoconnect=True)
class NlpTrialConfig(Model):
"""
Trial config for NLP. epoch_num is fixed at 50.
Attributes
----------
arch: dict
aka recepie in NAS-NLP-Benchmark repo (https://github.com/fmsnew/nas-bench-nlp-release).
an arch has multiple Node, Node_input_n and Node_op.
``Node`` can be ``node_n`` or ``h_new_n`` or ``f/i/o/j(_act)`` etc. (n is an int number and need not to be consecutive)
``Node_input_n`` can be ``Node`` or ``x`` etc.
``Node_op`` can be ``linear`` or ``activation_sigm`` or ``activation_tanh`` or ``elementwise_prod``
or ``elementwise_sum`` or ``activation_leaky_relu`` ...
e.g., {"h_new_0_input_0":"node_3","h_new_0_input_1":"x","h_new_0_op":"linear","node_2_input_0":"x",
"node_2_input_1":"h_prev_0","node_2_op":"linear","node_3_input_0":"node_2","node_3_op":"activation_leaky_relu"}
dataset: str
Dataset used. Could be ``ptb`` or ``wikitext-2``.
"""
arch = JSONField(json_dumps=json_dumps, index=True)
dataset = CharField(max_length=15, index=True, choices=[
'ptb',
'wikitext-2'
])
class Meta:
database = db
class NlpTrialStats(Model):
"""
Computation statistics for NAS-NLP-Benchmark.
Each corresponds to one trial result after 50 epoch.
Attributes
----------
config : NlpTrialConfig
Corresponding config for trial.
train_loss : float or None
Final loss on training data. Could be NaN (None).
val_loss : float or None
Final loss on validation data. Could be NaN (None).
test_loss : float or None
Final loss on test data. Could be NaN (None).
training_time : float
Time elapsed in seconds. aka wall_time in in NAS-NLP-Benchmark repo.
"""
config = ForeignKeyField(NlpTrialConfig, backref='trial_stats', index=True)
train_loss = FloatField(null=True)
val_loss = FloatField(null=True)
test_loss = FloatField(null=True)
training_time = FloatField(null=True)
class Meta:
database = db
class NlpIntermediateStats(Model):
"""
Computation statistics for NAS-NLP-Benchmark.
Each corresponds to one trial result for 1-50 epoch.
Attributes
----------
config : NlpTrialConfig
Corresponding config for trial.
train_loss : float or None
Final loss on training data. Could be NaN (None).
val_loss : float or None
Final loss on validation data. Could be NaN (None).
test_loss : float or None
Final loss on test data. Could be NaN (None).
training_time : float
Time elapsed in seconds. aka wall_time in in NAS-NLP-Benchmark repo.
"""
trial = ForeignKeyField(NlpTrialStats, backref='intermediates', index=True)
current_epoch = IntegerField(index=True)
train_loss = FloatField(null=True)
val_loss = FloatField(null=True)
test_loss = FloatField(null=True)
training_time = FloatField(null=True)
class Meta:
database = db
|