Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]
def test_linearize_metrics():
entries = [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 5, datetime.datetime.utcnow(), 50),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 15, datetime.datetime.utcnow(), 150),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
]
linearized = linearize_metrics(entries)
assert type(linearized) == dict
assert len(linearized.keys()) == 2
assert "training.loss" in linearized
assert "training.accuracy" in linearized
assert len(linearized["training.loss"]["steps"]) == 2
assert len(linearized["training.loss"]["values"]) == 2
assert len(linearized["training.loss"]["timestamps"]) == 2
assert len(linearized["training.accuracy"]["steps"]) == 4
assert len(linearized["training.accuracy"]["values"]) == 4
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]
def logged_metrics():
return [
ScalarMetricLogEntry("training.loss", 10, datetime.datetime.utcnow(), 1),
ScalarMetricLogEntry("training.loss", 20, datetime.datetime.utcnow(), 2),
ScalarMetricLogEntry("training.loss", 30, datetime.datetime.utcnow(), 3),
ScalarMetricLogEntry("training.accuracy", 10, datetime.datetime.utcnow(), 100),
ScalarMetricLogEntry("training.accuracy", 20, datetime.datetime.utcnow(), 200),
ScalarMetricLogEntry("training.accuracy", 30, datetime.datetime.utcnow(), 300),
ScalarMetricLogEntry("training.loss", 40, datetime.datetime.utcnow(), 10),
ScalarMetricLogEntry("training.loss", 50, datetime.datetime.utcnow(), 20),
ScalarMetricLogEntry("training.loss", 60, datetime.datetime.utcnow(), 30),
]