Пример #1
0
def create_network(name, *args, **kwargs):
    if name == 'ghostnet':
        return ghostnet_1x(*args, **kwargs)
    if name == 'ghostnet_nose':
        return ghostnet_nose_1x(*args, **kwargs)
    if name == 'ghostnet-600':
        return ghostnet_600m(*args, **kwargs)
    raise NotImplementedError(f"{name} is not implemented in the repo")
Пример #2
0
                            device_target="Ascend",
                            device_id=device_id,
                            save_graphs=False)
    elif args_opt.platform == "GPU":
        config_platform = config_gpu
        context.set_context(mode=context.GRAPH_MODE,
                            device_target="GPU",
                            save_graphs=False)
    else:
        raise ValueError("Unsupport platform.")

    loss = nn.SoftmaxCrossEntropyWithLogits(is_grad=False,
                                            sparse=True,
                                            reduction='mean')

    net = ghostnet_1x(num_classes=config_platform.num_classes)

    if args_opt.platform == "Ascend":
        net.to_float(mstype.float16)
        for _, cell in net.cells_and_names():
            if isinstance(cell, nn.Dense):
                cell.to_float(mstype.float32)

    dataset = create_dataset(dataset_path=args_opt.dataset_path,
                             do_train=False,
                             config=config_platform,
                             platform=args_opt.platform,
                             batch_size=config_platform.batch_size)
    step_size = dataset.get_dataset_size()

    if args_opt.checkpoint_path: