MCPcopy Create free account
hub / github.com/mlco2/codecarbon / main

Function main

examples/mnist_random_search.py:30–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28
29
30def main():
31 mnist = tf.keras.datasets.mnist
32
33 (x_train, y_train), (x_test, y_test) = mnist.load_data()
34 x_train, x_test = x_train / 255.0, x_test / 255.0
35
36 tuner = RandomSearchTuner(
37 build_model,
38 objective="val_accuracy",
39 directory="random_search_results",
40 project_name="codecarbon",
41 max_trials=3,
42 )
43
44 tracker = EmissionsTracker(project_name="mnist_random_search")
45 tracker.start()
46 tuner.search(x_train, y_train, epochs=10, validation_data=(x_test, y_test))
47 emissions = tracker.stop()
48
49 print(f"Emissions : {emissions} kg CO₂")
50
51
52if __name__ == "__main__":

Callers 1

Calls 4

EmissionsTrackerClass · 0.90
RandomSearchTunerClass · 0.85
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…