コード例 #1
0
    def __init__(self, resnet_size_choices=None):
        super(ResnetArgParser, self).__init__(parents=[
            parsers.BaseParser(),
            parsers.PerformanceParser(),
            parsers.ImageModelParser(),
            parsers.ExportParser(),
            parsers.BenchmarkParser(),
        ])

        self.add_argument(
            '--version',
            '-v',
            type=int,
            choices=[1, 2],
            default=resnet_model.DEFAULT_VERSION,
            help='Version of ResNet. (1 or 2) See README.md for details.')

        self.add_argument(
            '--resnet_size',
            '-rs',
            type=int,
            default=50,
            choices=resnet_size_choices,
            help='[default: %(default)s] The size of the ResNet model to use.',
            metavar='<RS>' if resnet_size_choices is None else None)
コード例 #2
0
 def __init__(self):
   super(TestParser, self).__init__(parents=[
       parsers.BaseParser(multi_gpu=True, num_gpu=False),
       parsers.PerformanceParser(num_parallel_calls=True, inter_op=True,
                                 intra_op=True, use_synthetic_data=True),
       parsers.ImageModelParser(data_format=True),
       parsers.BenchmarkParser(benchmark_log_dir=True, bigquery_uploader=True)
   ])
コード例 #3
0
    def __init__(self):
        super(MNISTArgParser, self).__init__(parents=[
            parsers.BaseParser(multi_gpu=True, num_gpu=False),
            parsers.ImageModelParser(),
            parsers.ExportParser(),
        ])

        self.set_defaults(data_dir=DATA_DIR,
                          model_dir=MODEL_DIR,
                          export_dir=EXPORT_DIR,
                          batch_size=100,
                          train_epochs=1)
コード例 #4
0
    def __init__(self):
        super(ArgParser, self).__init__(
            parents=[parsers.BaseParser(),
                     parsers.ImageModelParser()])

        # self.add_argument(
        #     '--export_dir',
        #     type=str)

        self.add_argument('--data_root', type=str)

        self.add_argument('--image_size', type=int)

        self.set_defaults(
            # data_dir='./data',
            model_dir=os.path.join(sys.path[0], 'fire', 'model'),
            export_dir=os.path.join(sys.path[0], 'fire', 'export'),
            data_root=os.path.join(sys.path[0], 'fire', 'data', 'tfrecords'),
            image_size=28,
            batch_size=5,
            train_epochs=1,
            data_format='channels_first')
コード例 #5
0
    def __init__(self, resnet_size_choices=None):
        super(ResnetArgParser, self).__init__(parents=[
            parsers.BaseParser(multi_gpu=False),
            parsers.PerformanceParser(num_parallel_calls=False),
            parsers.ImageModelParser(),
            parsers.ExportParser(),
            parsers.BenchmarkParser(),
        ])

        self.add_argument(
            '--version',
            '-v',
            type=int,
            choices=[1, 2, 14, 24, 34],
            default=resnet_model.DEFAULT_VERSION,
            help=
            'Version of ResNet. (1, 2, 14 or 24, 34) See README.md for details.'
        )

        self.add_argument(
            '--version_t',
            '-vt',
            type=int,
            choices=[1, 2, 14],
            default=resnet_model.DEFAULT_VERSION,
            help=
            'Version of ResNet Teacher. (1, 2 or 14) See README.md for details.'
        )

        self.add_argument(
            '--resnet_size',
            '-rs',
            type=int,
            default=50,
            choices=resnet_size_choices,
            help='[default: %(default)s] The size of the ResNet model to use.',
            metavar='<RS>' if resnet_size_choices is None else None)

        self.add_argument(
            '--final_size',
            '-fs',
            type=int,
            default=2048,
            help='[default: %(default)s] The final size for dense layer.',
            metavar='<FS>')

        self.add_argument(
            "--pickle_model",
            "-pm",
            default="./gap_save/gap_pruned.pkl",
            help=
            "[default: %(default)s] The location of the pruned model param file "
            "files.",
            metavar="<PM>",
        )

        self.add_argument(
            "--random_init",
            "-ri",
            action='store_true',
            help=
            "[default: %(default)s] random_init: If True the gap fine-tune is from scratch."
        )

        self.add_argument(
            "--enable_kd",
            "-ek",
            action='store_true',
            help=
            "[default: %(default)s] enable_kd: If True knowledge distillation is enabled."
        )

        self.add_argument(
            '--kd_size',
            '-ks',
            type=int,
            default=50,
            choices=resnet_size_choices,
            help=
            '[default: %(default)s] The size of the ResNet model (teach) to use.',
            metavar='<KS>' if resnet_size_choices is None else None)

        self.add_argument(
            "--temp_dst",
            "-tdst",
            type=float,
            default=2.,
            help=
            '[default: %(default)s] temp_dst: temperature for knowledge distillation.',
            metavar="<TDST>")

        self.add_argument(
            "--w_dst",
            "-wdst",
            type=float,
            default=2.,
            help=
            '[default: %(default)s] w_dst: balance factor for knowledge distillation.',
            metavar="<WDST>")

        self.add_argument(
            "--mix_up",
            "-mu",
            action='store_true',
            help="[default: %(default)s] mix_up: If True mix_up is enabled.")

        self.add_argument(
            '--mx_mode',
            '-mmd',
            type=int,
            default=0,
            help=
            '[default: %(default)s] the mode of mixup: randome or reverse.',
            metavar='<MMD>')

        self.add_argument(
            "--enable_quantize",
            "-eqz",
            action='store_true',
            help=
            "[default: %(default)s] enable_quantize: If True quantization-aware training is enabled."
        )

        self.add_argument(
            "--online_quantize",
            "-oqz",
            action='store_true',
            help=
            "[default: %(default)s] enable_quantize: If True online quantization-aware training is enabled."
        )

        self.add_argument('--q_bits',
                          '-qbt',
                          type=int,
                          default=8,
                          help='[default: %(default)s] quantization bits.',
                          metavar='<QBT>')

        self.add_argument('--copy_num',
                          '-cnum',
                          type=int,
                          default=10,
                          help='[default: %(default)s] quantization copies.',
                          metavar='<CNUM>')

        self.add_argument(
            '--q_mode',
            '-qme',
            type=int,
            default=1,
            help='[default: %(default)s] quantization method (KL, MAX, Perc.).',
            metavar='<QME>')

        self.add_argument(
            "--enable_at",
            "-eat",
            action='store_true',
            help=
            "[default: %(default)s] enable_at: If True attention transfer is enabled."
        )

        self.add_argument(
            "--w_at",
            "-wat",
            type=float,
            default=8.,
            help=
            '[default: %(default)s] w_at: balance factor for attention transfer.',
            metavar="<WDST>")

        self.add_argument(
            "--oss_load",
            "-osl",
            action='store_true',
            help=
            "[default: %(default)s] oss_load: If True dataset is loaded from oss."
        )
コード例 #6
0
  def __init__(self, resnet_size_choices=None):
    super(ResnetArgParser, self).__init__(parents=[
        parsers.BaseParser(),
        parsers.PerformanceParser(),
        parsers.ImageModelParser(),
    ])

    self.add_argument(
        '--version', '-v', type=int, choices=[1, 2],
        default=resnet_model.DEFAULT_VERSION,
        help="Version of ResNet. (1 or 2) See README.md for details."
    )

    self.add_argument(
        '--resnet_size', '-rs', type=int, default=50,
        choices=resnet_size_choices,
        help="[default: %(default)s] The size of the ResNet model to use.",
        metavar='<RS>' if resnet_size_choices is None else None
    )

    self.add_argument(
        '--method', '-mt',
        default=resnet_model.DEFAULT_METHOD,
        help = "[default: %(default)s] The type of tensor decomposition used to compress the reference model."
    )
    
    self.add_argument(
        '--scope', '-sc',
        default=resnet_model.DEFAULT_SCOPE,
        help = "[default: %(default)s] The variable scope used with the tensor decomposition method."
    )

    self.add_argument(
        '--reference_model_dir', '-rd',
        help = "[default: %(default)s] The location of the reference model.",
        metavar = '<RD>'
        )
    
    self.add_argument(
        '--reference_model_checkpoint_name', '-rdcn',
        help = "[default: %(default)s] The name of the reference model checkpoint.",
        metavar = '<RDC>'
    )

    self.add_argument(
        '--output_model_dir', '-omd', default = '/tmp',
        help = "[default: %(default)s] The location of the tensorized model.",
        metavar = '<MD>'
    )

    self.add_argument(
        '--rate', '-cr', default = 1, type=float,
        help = "[default: %(default)d] The targeted compression rate of the tensorized model.",
        metavar = '<CR>'
    )

    self.add_argument(
        '--rate_decay', '-rdy', default = 'flat',
        help = "[default: %(default)d] The rate decay function used for dynamic rate change.",
        metavar = '<RDY>'
    )