Пример #1
0
    # attributes that need to be adjusted, once the Curriculum decides to use
    # a more difficult dataset
    # this is a 'map' of attribute name to a path in the trainer object
    attributes_to_adjust = [
        ('num_timesteps', ['predictor', 'localization_net']),
        ('num_timesteps', ['predictor', 'recognition_net']),
        ('num_timesteps', ['lossfun', '__self__']),
        ('num_labels', ['predictor', 'recognition_net']),
    ]

    # create train curriculum
    curriculum = BabyStepCurriculum(
        args.dataset_specification,
        FileBasedDataset,
        args.blank_label,
        attributes_to_adjust=attributes_to_adjust,
        trigger=(args.test_interval, 'iteration'),
        min_delta=0.1,
    )
    train_dataset, validation_dataset = curriculum.load_dataset(0)

    # the metrics object calculates the loss
    metrics = SoftmaxMetrics(
        args.blank_label,
        args.char_map,
        train_dataset.num_timesteps,
        image_size,
        area_loss_factor=args.area_factor,
        aspect_ratio_loss_factor=args.aspect_factor,
        area_scaling_factor=args.area_scale_factor,
        uses_original_data=args.is_original_fsns,
Пример #2
0
    # attributes that need to be adjusted, once the Curriculum decides to use
    # a more difficult dataset
    # this is a 'map' of attribute name to path in trainer object
    attributes_to_adjust = [
        ('num_timesteps', ['predictor', 'localization_net']),
        ('num_timesteps', ['predictor', 'recognition_net']),
        ('num_timesteps', ['lossfun', '__self__']),
        ('num_labels', ['predictor', 'recognition_net']),
    ]

    curriculum = BabyStepCurriculum(args.dataset_specification,
                                    TextRecFileDataset,
                                    args.blank_label,
                                    attributes_to_adjust=attributes_to_adjust,
                                    trigger=(args.test_interval, 'iteration'),
                                    min_delta=1.0,
                                    dataset_args={
                                        'char_map': args.char_map,
                                        'resize_size': target_shape,
                                        'blank_label': args.blank_label,
                                    })

    train_dataset, validation_dataset = curriculum.load_dataset(0)
    train_dataset.resize_size = image_size
    validation_dataset.resize_size = image_size

    metrics = TextRecSoftmaxMetrics(
        args.blank_label,
        args.char_map,
        train_dataset.num_timesteps,
        image_size,