Layers¶
Albert¶
Classes:
|
Wraps the ALBERT module from Tensorflow Hub in a Keras Layer. |
-
class
layers.albert_layer.AlbertLayer(model_url, albert_model='base', output_mode='sequence', **kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerWraps the ALBERT module from Tensorflow Hub in a Keras Layer.
Methods:
build(input_shape)call(x[, mask])compute_output_shape(input_shape)-
build(input_shape)¶
-
call(x, mask=None)¶
-
compute_output_shape(input_shape)¶
-
get_config()¶
-
BERT¶
Classes:
|
Wraps the BERT module from Tensorflow Hub in a Keras Layer. |
-
class
layers.bert_layer.BertLayer(model_url, bert_model='base', num_fine_tune_layers=12, output_mode='sequence', **kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerWraps the BERT module from Tensorflow Hub in a Keras Layer.
Methods:
build(input_shape)call(inputs, **kwargs)compute_output_shape(input_shape)-
build(input_shape)¶
-
call(inputs, **kwargs)¶
-
compute_output_shape(input_shape)¶
-
ConveRT¶
Classes:
|
Wraps the ConveRT Tensorflow Hub module in a Keras Layer. |
-
class
layers.convert_layer.ConveRTLayer(**kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerWraps the ConveRT Tensorflow Hub module in a Keras Layer.
Methods:
build(input_shape)call(x[, mask])compute_output_shape(input_shape)-
build(input_shape)¶
-
call(x, mask=None)¶
-
compute_output_shape(input_shape)¶
-
ELMo¶
Classes:
|
Wraps the Elmo module from Tensorflow Hub in a Keras Layer. |
-
class
layers.elmo_layer.ElmoLayer(model_url, input_mode='default', output_mode='default', **kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerWraps the Elmo module from Tensorflow Hub in a Keras Layer.
Methods:
build(input_shape)call(x[, mask])compute_output_shape(input_shape)-
build(input_shape)¶
-
call(x, mask=None)¶
-
compute_output_shape(input_shape)¶
-
get_config()¶
-
mLSTM¶
Classes:
|
Wraps the mLSTM Character Language Model in a Keras Layer. |
|
-
class
layers.mlstm_char_lm_layer.MLSTMCharLMLayer(batch_size=32, max_seq_length=640, dimensions=4096, output_mode='mean', **kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerWraps the mLSTM Character Language Model in a Keras Layer.
Radford, A., Jozefowicz, R. and Sutskever, I. (2018) ‘Learning to Generate Reviews and Discovering Sentiment’, arXiv. Available at: http://arxiv.org/abs/1704.01444 https://github.com/openai/generating-reviews-discovering-sentiment
Methods:
build(input_shape)call(x, **kwargs)compute_output_shape(input_shape)-
build(input_shape)¶
-
call(x, **kwargs)¶
-
compute_output_shape(input_shape)¶
-
-
class
layers.mlstm_char_lm_layer.Model(weights_path, batch_size=128, max_seq_length=64, hidden_dim=4096)¶ Bases:
objectMethods:
batch_pad(xs, n_batch, n_steps)ceil_round_step(n, step)cell_transform(xs[, indexes])embd(X, ndim[, scope])fc(x, n_out, act[, wn, bias, scope])iter_data(*data, **kwargs)load_params(shape, dtype, *args, **kwargs)mlstm(inputs, c, h, M, n_dim[, scope, wn])model(X, S[, M, reuse])preprocess(text, max_seq_length[, …])seq_cells(xmb, mmb, smb)seq_rep(xmb, mmb, smb)transform(xs)-
static
batch_pad(xs, n_batch, n_steps)¶
-
static
ceil_round_step(n, step)¶
-
cell_transform(xs, indexes=None)¶
-
embd(X, ndim, scope='embedding')¶
-
fc(x, n_out, act, wn=False, bias=True, scope='fc')¶
-
static
iter_data(*data, **kwargs)¶
-
load_params(shape, dtype, *args, **kwargs)¶
-
mlstm(inputs, c, h, M, n_dim, scope='lstm', wn=False)¶
-
model(X, S, M=None, reuse=False)¶
-
static
preprocess(text, max_seq_length, front_pad='\n ', end_pad=' ')¶
-
seq_cells(xmb, mmb, smb)¶
-
seq_rep(xmb, mmb, smb)¶
-
transform(xs)¶
-
static
NNLM¶
Classes:
|
Wraps the Universal Sentence Encoder module from Tensorflow Hub in a Keras Layer. |
-
class
layers.nnlm_layer.NeuralNetworkLanguageModelLayer(model_url, **kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerWraps the Universal Sentence Encoder module from Tensorflow Hub in a Keras Layer.
Methods:
build(input_shape)call(x[, mask])compute_output_shape(input_shape)-
build(input_shape)¶
-
call(x, mask=None)¶
-
compute_output_shape(input_shape)¶
-
USE¶
Classes:
|
Wraps the Universal Sentence Encoder module from Tensorflow Hub in a Keras Layer. |
-
class
layers.use_layer.UniversalSentenceEncoderLayer(model_url, **kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerWraps the Universal Sentence Encoder module from Tensorflow Hub in a Keras Layer.
Methods:
build(input_shape)call(x[, mask])compute_output_shape(input_shape)-
build(input_shape)¶
-
call(x, mask=None)¶
-
compute_output_shape(input_shape)¶
-
Folding¶
Classes:
|
Folding Layer code from: “https://github.com/AlexYangLi/TextClassification” |
-
class
layers.folding.Folding(**kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerFolding Layer code from: “https://github.com/AlexYangLi/TextClassification”
Methods:
build(input_shape)call(x[, mask])compute_output_shape(input_shape)-
build(input_shape)¶
-
call(x, mask=None)¶
-
compute_output_shape(input_shape)¶
-
K Max Pooling¶
Classes:
|
Implemetation of temporal k-max pooling layer, which was first proposed in: |
-
class
layers.kmaxpooling.KMaxPooling(k=1, **kwargs)¶ Bases:
tensorflow.python.keras.engine.base_layer.LayerImplemetation of temporal k-max pooling layer, which was first proposed in:
Kalchbrenner, N., Grefenstette, E. and Blunsom, P. (2014) A Convolutional Neural Network for Modelling Sentences. Proceedings of the 52nd Annual Meeting of the Association for Computational Linguistics.
This layer allows to detect the k most important features in a sentence, independent of their specific position, preserving their relative order.
Layer code from: “https://github.com/AlexYangLi/TextClassification”
Methods:
build(input_shape)call(x[, mask])compute_output_shape(input_shape)-
build(input_shape)¶
-
call(x, mask=None)¶
-
compute_output_shape(input_shape)¶
-
get_config()¶
-