google-research
51 строка · 1.8 Кб
1# coding=utf-8
2# Copyright 2024 The Google Research Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16"""Runs distributional-skew UQ experiments on MNIST.
17
18Lightweight wrapper around experiment.py -- mostly useful to keep flags and
19py_binary boilerplate out of colab during development.
20"""
21
22from __future__ import absolute_import
23from __future__ import division
24from __future__ import print_function
25
26from absl import app
27from absl import flags
28from uq_benchmark_2019.mnist import experiment
29from uq_benchmark_2019.mnist import models_lib
30
31FLAGS = flags.FLAGS
32flags.DEFINE_enum('arch', None, models_lib.ARCHITECTURES,
33'Name of NN architecture.')
34flags.DEFINE_enum('method', None, models_lib.METHODS,
35'Name of modeling method.')
36flags.DEFINE_string('output_dir', None, 'Output directory.')
37
38flags.DEFINE_integer('test_level', 0,
39'(0) no testing, (1) quick training (2) fake data.')
40flags.DEFINE_integer('task', 0, 'Task number.')
41
42
43def main(argv):
44if len(argv) > 1:
45raise app.UsageError('Too many command-line arguments.')
46experiment.run(FLAGS.method, FLAGS.arch,
47FLAGS.output_dir.replace('%task%', str(FLAGS.task)),
48test_level=FLAGS.test_level)
49
50if __name__ == '__main__':
51app.run(main)
52