def Resnext101(model, loss_scale, dtype='float'):
    initializer = (PseudoFP16Initializer
                   if dtype == 'float16' else Initializer)
    with brew.arg_scope(
        [brew.conv, brew.fc],
            WeightInitializer=initializer,
            BiasInitializer=initializer,
    ):
        # residual network
        pred = resnet.create_resnext(
            model,
            "data",
            num_input_channels=3,
            num_labels=1000,
            label="label",
            num_layers=101,
            num_groups=32,
            num_width_per_group=4,
            no_bias=True,
            no_loss=True,
        )
        if dtype == 'float16':
            pred = model.net.HalfToFloat(pred, pred + '_fp32')

        softmax, loss = model.SoftmaxWithLoss([pred, 'label'],
                                              ['softmax', 'loss'])
        prefix = model.net.Proto().name
        loss = model.net.Scale(loss, prefix + "_loss", scale=loss_scale)
        brew.accuracy(model, [softmax, "label"], prefix + "_accuracy")
        return [loss]
    def create_resnext_model_ops(model, loss_scale):
        initializer = (PseudoFP16Initializer if args.dtype == 'float16'
                       else Initializer)

        with brew.arg_scope([brew.conv, brew.fc],
                            WeightInitializer=initializer,
                            BiasInitializer=initializer,
                            enable_tensor_core=args.enable_tensor_core,
                            float16_compute=args.float16_compute):
            pred = resnet.create_resnext(
                model,
                "data",
                num_input_channels=args.num_channels,
                num_labels=args.num_labels,
                num_layers=args.num_layers,
                num_groups=args.resnext_num_groups,
                num_width_per_group=args.resnext_width_per_group,
                no_bias=True,
                no_loss=True,
            )

        if args.dtype == 'float16':
            pred = model.net.HalfToFloat(pred, pred + '_fp32')

        softmax, loss = model.SoftmaxWithLoss([pred, 'label'],
                                              ['softmax', 'loss'])
        loss = model.Scale(loss, scale=loss_scale)
        brew.accuracy(model, [softmax, "label"], "accuracy", top_k=1)
        brew.accuracy(model, [softmax, "label"], "accuracy_top5", top_k=5)
        return [loss]
 def create_resnext_model_ops(model, loss_scale=1.0):
     # residual network
     [softmax, loss] = resnet.create_resnext(model,
                                              "data",
                                              num_input_channels=3,
                                              num_labels=num_labels,
                                              label="label",
                                              num_layers=num_layers,
                                              num_groups=num_groups,
                                              num_width_per_group=num_width_per_group,
                                              no_bias=True, )
     prefix = model.net.Proto().name
     loss = model.net.Scale(loss, prefix + "_loss", scale=loss_scale)
     brew.accuracy(model, [softmax, "label"], prefix + "_accuracy")
     return [loss]