Skip to content

Commit

Permalink
Merge pull request #153 from Hector-hedb12/issue_150_lstm_binary_text…
Browse files Browse the repository at this point in the history
…_classifier

Issue 150: Long Short-Term Memory (LSTM) Binary Classifier for texts
  • Loading branch information
csala authored Apr 22, 2019
2 parents a83234c + 6a366fa commit 2f32f2b
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 0 deletions.
137 changes: 137 additions & 0 deletions mlprimitives/jsons/keras.Sequential.LSTMBinaryTextClassifier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"name": "keras.Sequential.LSTMBinaryTextClassifier",
"contributors": [
"Hector Dominguez <hedb_12@hotmail.com>"
],
"description": "Long Short-Term Memory (LSTM) Binary Classifier for texts",
"classifiers": {
"type": "estimator",
"subtype": "classifier"
},
"modalities": [],
"primitive": "mlprimitives.adapters.keras.Sequential",
"fit": {
"method": "fit",
"args": [
{
"name": "X",
"type": "ndarray"
},
{
"name": "y",
"type": "array"
},
{
"name": "vocabulary_size",
"type": "int",
"description": "vocabulary size + 1: number of known words in input."
}
]
},
"produce": {
"method": "predict",
"args": [
{
"name": "X",
"type": "ndarray"
}
],
"output": [
{
"name": "y",
"type": "array"
}
]
},
"hyperparameters": {
"fixed": {
"classification": {
"type": "bool",
"default": true
},
"loss": {
"type": "str",
"default": "keras.losses.binary_crossentropy"
},
"optimizer": {
"type": "str",
"default": "keras.optimizers.RMSprop"
},
"metrics": {
"type": "list",
"default": [
"accuracy"
]
},
"epochs": {
"type": "int",
"default": 20
},
"verbose": {
"type": "int",
"default": 0,
"range": [
0,
2
]
},
"layers": {
"type": "list",
"default": [
{
"class": "keras.layers.Embedding",
"parameters": {
"input_dim": "vocabulary_size",
"output_dim": "embedding_output_dim"
}
},
{
"class": "keras.layers.LSTM",
"parameters": {
"units": "lstm_units"
}
},
{
"class": "keras.layers.Dropout",
"parameters": {
"rate": "dropout_rate"
}
},
{
"class": "keras.layers.Dense",
"parameters": {
"units": 2,
"activation": "sigmoid"
}
}
]
}
},
"tunable": {
"embedding_output_dim": {
"type": "int",
"default": 100,
"range": [
100,
500
]
},
"lstm_units": {
"type": "int",
"default": 100,
"range": [
100,
500
]
},
"dropout_rate": {
"type": "float",
"default": 0.5,
"range": [
0.0,
0.75
]
}
}
}
}
28 changes: 28 additions & 0 deletions pipelines/keras.Sequential.LSTMBinaryTextClassifier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"metadata": {
"name": "keras.Sequential.LSTMBinaryTextClassifier",
"data_type": "text",
"task_type": "classification"
},
"validation": {
"dataset": "personae"
},
"primitives": [
"mlprimitives.custom.counters.VocabularyCounter",
"mlprimitives.custom.feature_extraction.StringVectorizer",
"keras.Sequential.LSTMBinaryTextClassifier"
],
"output_names": {
"mlprimitives.custom.counters.VocabularyCounter#1": {
"counts": "vocabulary_size"
}
},
"init_params": {
"mlprimitives.custom.counters.VocabularyCounter#1": {
"add": 1
},
"keras.Sequential.LSTMBinaryTextClassifier#1": {
"epochs": 1
}
}
}

0 comments on commit 2f32f2b

Please sign in to comment.