MonoHime's picture
Add model config
bb282eb
{
"dataset_reader": {
"class_name": "basic_classification_reader",
"x": "text",
"y": "sentiment",
"data_path": "/train/",
"train": "train.csv",
"valid": "valid.csv"
},
"dataset_iterator": {
"class_name": "basic_classification_iterator",
"seed": 42
},
"chainer": {
"in": [
"x"
],
"in_y": [
"y"
],
"pipe": [
{
"id": "classes_vocab",
"class_name": "simple_vocab",
"fit_on": [
"y"
],
"save_path": "custom_bert/classes.dict",
"load_path": "custom_bert/classes.dict",
"in": "y",
"out": "y_ids"
},
{
"class_name": "transformers_bert_preprocessor",
"vocab_file": "vocab.txt",
"do_lower_case": false,
"max_seq_length": 512,
"in": ["x"],
"out": ["tokens", "subword_tokens", "subword_tok_ids", "startofword_markers", "attention_mask"]
},
{
"class_name": "transformers_bert_embedder",
"id": "my_embedder",
"bert_config_path": "config.json",
"truncate": false,
"load_path": "custom_bert",
"in": ["subword_tok_ids", "startofword_markers", "attention_mask"],
"out": ["word_emb", "subword_emb", "max_emb", "mean_emb", "pooler_output"]
},
{
"in": "y_ids",
"out": "y_onehot",
"class_name": "one_hotter",
"depth": "#classes_vocab.len",
"single_vector": true
},
{
"in": [
"word_emb"
],
"in_y": [
"y_onehot"
],
"out": [
"y_pred_probas"
],
"main": true,
"class_name": "keras_classification_model",
"save_path": "custom_bert/model",
"load_path": "custom_bert/model",
"embedding_size": "#my_embedder.dim",
"n_classes": "#classes_vocab.len",
"kernel_sizes_cnn": [
3,
5,
7
],
"filters_cnn": 512,
"optimizer": "Adam",
"learning_rate": 0.01,
"learning_rate_decay": 0.1,
"loss": "categorical_crossentropy",
"last_layer_activation": "softmax",
"coef_reg_cnn": 1e-3,
"coef_reg_den": 1e-2,
"dropout_rate": 0.5,
"dense_size": 100,
"model_name": "cnn_model"
},
{
"in": "y_pred_probas",
"out": "y_pred_ids",
"class_name": "proba2labels",
"max_proba": true
},
{
"in": "y_pred_ids",
"out": "y_pred_labels",
"ref": "classes_vocab"
}
],
"out": [
"y_pred_labels"
]
},
"train": {
"epochs": 3,
"batch_size": 16,
"metrics": [
"accuracy",
"f1_macro",
"f1_weighted",
{
"name": "roc_auc",
"inputs": ["y_onehot", "y_pred_probas"]
}
],
"validation_patience": 1,
"val_every_n_epochs": 1,
"log_every_n_epochs": 1,
"show_examples": false,
"evaluation_targets": [
"train",
"valid"
],
"class_name": "nn_trainer"
}
}