基于孪生网络的单样本学习

此示例可视为在 Omniglot 数据集上进行单样本学习的简单基线。任务是,给定两个手写字符的图像,判断它们是否为同一字符的两个不同实例。

image_path_1 image_path_2 相似度
balinese/character01/0108_13.png balinese/character01/0108_18.png 1
balinese/character01/0108_13.png balinese/character08/0115_12.png 0
balinese/character01/0108_04.png balinese/character01/0108_08.png 1
balinese/character01/0108_11.png balinese/character05/0112_02.png 0
ludwig experiment \
--dataset balinese_characters.csv \
  --config config.yaml

使用 config.yaml

input_features:
    -
        name: image_path_1
        type: image
        encoder: 
            type: stacked_cnn
        preprocessing:
          width: 28
          height: 28
          resize_image: true
    -
        name: image_path_2
        type: image
        encoder: 
            type: stacked_cnn
        preprocessing:
          width: 28
          height: 28
          resize_image: true
        tied: image_path_1

combiner:
    type: concat
    num_fc_layers: 2
    output_size: 256

output_features:
    -
        name: similarity
        type: binary