summaryrefslogtreecommitdiff
path: root/training
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-09-30 23:11:11 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-09-30 23:11:11 +0200
commit0c578ab3e79c00389f6aab79329a7652f2ce6f22 (patch)
tree9b69c37a874e2e89fd4b2389f8c7a02bfc41cbb6 /training
parent7b8705f382b1642cf171cf7fcd01295104b9deef (diff)
Add new config files
Diffstat (limited to 'training')
-rw-r--r--training/conf/datamodule/iam_lines.yaml7
-rw-r--r--training/conf/experiment/cnn_htr_char_lines.yaml109
-rw-r--r--training/conf/experiment/vqgan_htr_char.yaml61
-rw-r--r--training/conf/experiment/vqgan_htr_char_iam_lines.yaml90
-rw-r--r--training/conf/experiment/vqgan_iam_lines.yaml105
5 files changed, 372 insertions, 0 deletions
diff --git a/training/conf/datamodule/iam_lines.yaml b/training/conf/datamodule/iam_lines.yaml
new file mode 100644
index 0000000..d3c2af8
--- /dev/null
+++ b/training/conf/datamodule/iam_lines.yaml
@@ -0,0 +1,7 @@
+_target_: text_recognizer.data.iam_lines.IAMLines
+batch_size: 8
+num_workers: 12
+train_fraction: 0.8
+augment: true
+pin_memory: false
+# word_pieces: true
diff --git a/training/conf/experiment/cnn_htr_char_lines.yaml b/training/conf/experiment/cnn_htr_char_lines.yaml
new file mode 100644
index 0000000..08d9282
--- /dev/null
+++ b/training/conf/experiment/cnn_htr_char_lines.yaml
@@ -0,0 +1,109 @@
+# @package _global_
+
+defaults:
+ - override /mapping: null
+ - override /criterion: null
+ - override /datamodule: null
+ - override /network: null
+ - override /model: null
+ - override /lr_schedulers: null
+ - override /optimizers: null
+
+
+criterion:
+ _target_: torch.nn.CrossEntropyLoss
+ ignore_index: 3
+
+mapping:
+ _target_: text_recognizer.data.emnist_mapping.EmnistMapping
+ # extra_symbols: [ "\n" ]
+
+optimizers:
+ madgrad:
+ _target_: madgrad.MADGRAD
+ lr: 1.0e-4
+ momentum: 0.9
+ weight_decay: 0
+ eps: 1.0e-6
+
+ parameters: network
+
+lr_schedulers:
+ network:
+ _target_: torch.optim.lr_scheduler.CosineAnnealingLR
+ T_max: 1024
+ eta_min: 4.5e-6
+ last_epoch: -1
+ interval: epoch
+ monitor: val/loss
+
+datamodule:
+ _target_: text_recognizer.data.iam_lines.IAMLines
+ batch_size: 24
+ num_workers: 12
+ train_fraction: 0.8
+ augment: true
+ pin_memory: false
+
+network:
+ _target_: text_recognizer.networks.conv_transformer.ConvTransformer
+ input_dims: [1, 56, 1024]
+ hidden_dim: 128
+ encoder_dim: 1280
+ dropout_rate: 0.2
+ num_classes: 58
+ pad_index: 3
+ encoder:
+ _target_: text_recognizer.networks.encoders.efficientnet.EfficientNet
+ arch: b0
+ out_channels: 1280
+ stochastic_dropout_rate: 0.2
+ bn_momentum: 0.99
+ bn_eps: 1.0e-3
+ decoder:
+ _target_: text_recognizer.networks.transformer.Decoder
+ dim: 128
+ depth: 3
+ num_heads: 4
+ attn_fn: text_recognizer.networks.transformer.attention.Attention
+ attn_kwargs:
+ dim_head: 32
+ dropout_rate: 0.2
+ norm_fn: torch.nn.LayerNorm
+ ff_fn: text_recognizer.networks.transformer.mlp.FeedForward
+ ff_kwargs:
+ dim_out: null
+ expansion_factor: 4
+ glu: true
+ dropout_rate: 0.2
+ cross_attend: true
+ pre_norm: true
+ rotary_emb: null
+
+model:
+ _target_: text_recognizer.models.transformer.TransformerLitModel
+ max_output_len: 89
+ start_token: <s>
+ end_token: <e>
+ pad_token: <p>
+
+trainer:
+ _target_: pytorch_lightning.Trainer
+ stochastic_weight_avg: false
+ auto_scale_batch_size: binsearch
+ auto_lr_find: false
+ gradient_clip_val: 0
+ fast_dev_run: false
+ gpus: 1
+ precision: 16
+ max_epochs: 1024
+ terminate_on_nan: true
+ weights_summary: top
+ limit_train_batches: 1.0
+ limit_val_batches: 1.0
+ limit_test_batches: 1.0
+ resume_from_checkpoint: null
+ accumulate_grad_batches: 4
+ overfit_batches: 0.0
+
+# summary: [[1, 1, 56, 1024], [1, 89]]
diff --git a/training/conf/experiment/vqgan_htr_char.yaml b/training/conf/experiment/vqgan_htr_char.yaml
new file mode 100644
index 0000000..426524f
--- /dev/null
+++ b/training/conf/experiment/vqgan_htr_char.yaml
@@ -0,0 +1,61 @@
+# @package _global_
+
+defaults:
+ - override /mapping: null
+ - override /network: null
+ - override /model: null
+
+mapping:
+ _target_: text_recognizer.data.emnist_mapping.EmnistMapping
+ extra_symbols: [ "\n" ]
+
+datamodule:
+ word_pieces: false
+ batch_size: 8
+ augment: false
+
+criterion:
+ ignore_index: 3
+
+network:
+ _target_: text_recognizer.networks.vq_transformer.VqTransformer
+ input_dims: [1, 576, 640]
+ encoder_dim: 32
+ hidden_dim: 256
+ dropout_rate: 0.1
+ num_classes: 58
+ pad_index: 3
+ no_grad: true
+ decoder:
+ _target_: text_recognizer.networks.transformer.Decoder
+ dim: 256
+ depth: 2
+ num_heads: 8
+ attn_fn: text_recognizer.networks.transformer.attention.Attention
+ attn_kwargs:
+ dim_head: 32
+ dropout_rate: 0.2
+ norm_fn: torch.nn.LayerNorm
+ ff_fn: text_recognizer.networks.transformer.mlp.FeedForward
+ ff_kwargs:
+ dim_out: null
+ expansion_factor: 4
+ glu: true
+ dropout_rate: 0.2
+ cross_attend: true
+ pre_norm: true
+ rotary_emb: null
+ pretrained_encoder_path: "training/logs/runs/2021-09-25/23-07-28"
+
+model:
+ _target_: text_recognizer.models.vq_transformer.VqTransformerLitModel
+ start_token: <s>
+ end_token: <e>
+ pad_token: <p>
+ max_output_len: 682 # 451
+ alpha: 1.0
+
+trainer:
+ max_epochs: 64
+ limit_train_batches: 0.1
+ limit_val_batches: 0.1
diff --git a/training/conf/experiment/vqgan_htr_char_iam_lines.yaml b/training/conf/experiment/vqgan_htr_char_iam_lines.yaml
new file mode 100644
index 0000000..9f4791f
--- /dev/null
+++ b/training/conf/experiment/vqgan_htr_char_iam_lines.yaml
@@ -0,0 +1,90 @@
+# @package _global_
+
+defaults:
+ - override /mapping: null
+ - override /criterion: null
+ - override /datamodule: null
+ - override /network: null
+ - override /model: null
+ - override /lr_schedulers: null
+ # - override /optimizers: null
+
+
+criterion:
+ _target_: text_recognizer.criterions.label_smoothing.LabelSmoothingLoss
+ smoothing: 0.1
+ ignore_index: 3
+
+mapping:
+ _target_: text_recognizer.data.emnist_mapping.EmnistMapping
+ # extra_symbols: [ "\n" ]
+
+lr_schedulers:
+ network:
+ _target_: torch.optim.lr_scheduler.CosineAnnealingLR
+ T_max: 512
+ eta_min: 4.5e-6
+ last_epoch: -1
+ interval: epoch
+ monitor: val/loss
+
+datamodule:
+ _target_: text_recognizer.data.iam_lines.IAMLines
+ batch_size: 4
+ num_workers: 12
+ train_fraction: 0.8
+ augment: false
+ pin_memory: false
+
+
+# optimizers:
+# - _target_: madgrad.MADGRAD
+# lr: 2.0e-4
+# momentum: 0.9
+# weight_decay: 0
+# eps: 1.0e-7
+# parameters: network
+
+network:
+ _target_: text_recognizer.networks.vq_transformer.VqTransformer
+ input_dims: [1, 56, 1024]
+ encoder_dim: 32
+ hidden_dim: 32
+ dropout_rate: 0.1
+ num_classes: 58
+ pad_index: 3
+ no_grad: true
+ decoder:
+ _target_: text_recognizer.networks.transformer.Decoder
+ dim: 32
+ depth: 4
+ num_heads: 8
+ attn_fn: text_recognizer.networks.transformer.attention.Attention
+ attn_kwargs:
+ dim_head: 32
+ dropout_rate: 0.2
+ norm_fn: torch.nn.LayerNorm
+ ff_fn: text_recognizer.networks.transformer.mlp.FeedForward
+ ff_kwargs:
+ dim_out: null
+ expansion_factor: 4
+ glu: true
+ dropout_rate: 0.2
+ cross_attend: true
+ pre_norm: true
+ rotary_emb: null
+ pretrained_encoder_path: "training/logs/runs/2021-09-26/23-27-57"
+
+model:
+ _target_: text_recognizer.models.vq_transformer.VqTransformerLitModel
+ start_token: <s>
+ end_token: <e>
+ pad_token: <p>
+ max_output_len: 89 # 451
+ alpha: 0.0
+
+trainer:
+ max_epochs: 512
+ # limit_train_batches: 0.1
+ # limit_val_batches: 0.1
+ # gradient_clip_val: 0.5
diff --git a/training/conf/experiment/vqgan_iam_lines.yaml b/training/conf/experiment/vqgan_iam_lines.yaml
new file mode 100644
index 0000000..8bdf415
--- /dev/null
+++ b/training/conf/experiment/vqgan_iam_lines.yaml
@@ -0,0 +1,105 @@
+# @package _global_
+
+defaults:
+ - override /network: null
+ - override /criterion: null
+ - override /datamodule: null
+ - override /model: lit_vqgan
+ - override /callbacks: wandb_vae
+ - override /optimizers: null
+ - override /lr_schedulers: null
+
+criterion:
+ _target_: text_recognizer.criterions.vqgan_loss.VQGANLoss
+ reconstruction_loss:
+ _target_: torch.nn.BCEWithLogitsLoss
+ reduction: mean
+ discriminator:
+ _target_: text_recognizer.criterions.n_layer_discriminator.NLayerDiscriminator
+ in_channels: 1
+ num_channels: 64
+ num_layers: 3
+ commitment_weight: 0.25
+ discriminator_weight: 0.8
+ discriminator_factor: 1.0
+ discriminator_iter_start: 1.5e4
+
+datamodule:
+ _target_: text_recognizer.data.iam_lines.IAMLines
+ batch_size: 24
+ num_workers: 12
+ train_fraction: 0.8
+ augment: true
+ pin_memory: false
+
+lr_schedulers:
+ generator:
+ _target_: torch.optim.lr_scheduler.CosineAnnealingLR
+ T_max: 64
+ eta_min: 4.5e-6
+ last_epoch: -1
+ interval: epoch
+ monitor: val/loss
+# discriminator:
+# _target_: torch.optim.lr_scheduler.CosineAnnealingLR
+# T_max: 64
+# eta_min: 0.0
+# last_epoch: -1
+#
+# interval: epoch
+# monitor: val/loss
+
+optimizers:
+ generator:
+ _target_: madgrad.MADGRAD
+ lr: 1.0e-4
+ momentum: 0.5
+ weight_decay: 0
+ eps: 1.0e-7
+ parameters: network
+
+ discriminator:
+ _target_: madgrad.MADGRAD
+ lr: 4.5e-6
+ momentum: 0.5
+ weight_decay: 0
+ eps: 1.0e-6
+ parameters: loss_fn.discriminator
+
+network:
+ _target_: text_recognizer.networks.vqvae.vqvae.VQVAE
+ hidden_dim: 256
+ embedding_dim: 32
+ num_embeddings: 512
+ decay: 0.99
+ encoder:
+ _target_: text_recognizer.networks.vqvae.encoder.Encoder
+ in_channels: 1
+ hidden_dim: 32
+ channels_multipliers: [1, 4, 8]
+ dropout_rate: 0.0
+ activation: mish
+ use_norm: true
+ num_residuals: 2
+ residual_channels: 32
+ decoder:
+ _target_: text_recognizer.networks.vqvae.decoder.Decoder
+ out_channels: 1
+ hidden_dim: 32
+ channels_multipliers: [8, 4, 1]
+ dropout_rate: 0.0
+ activation: mish
+ use_norm: true
+ num_residuals: 2
+ residual_channels: 32
+
+trainer:
+ max_epochs: 64
+ # limit_train_batches: 0.1
+ # limit_val_batches: 0.1
+ # gradient_clip_val: 100
+
+# tune: false
+# train: true
+# test: false
+summary: [2, 1, 56, 1024]