Implementation of kim2014convolutional
Project description
# kim2014convolutional
This package provides a simple implementation of the models proposed in
the paper:
> Kim, Y. (2014). Convolutional neural networks for sentence classification. arXiv preprint arXiv:1408.5882.
## Installation
This package depends on the [Keras](https://keras.io/) library. This
means you will need to install a backend library in order to use this
module. Take a look to [Keras installation](https://keras.io/#installation)
to get more information.
After having installed the backend of yout choice, you just need to
install this package using [pip](https://pypi.org/):
pip install kim2014convolutional
## Usage
This package only provides a single model. To get detailed information
on the parameters the model accepts, take a look to the documentation
included with the module class.
Here is a complete example of instantiation of the `CNN-multichannel`
model proposed in the original paper using two channel of randomly
initialized word embeddings:
```python
import numpy as np
import numpy.random as rng
vocabulary_size = 10000
embedding_size = 300
value = np.sqrt(6/embedding_size)
weights_shape = (vocabulary_size+1, embedding_size)
weights = rng.uniform(low=-value, high=value, size=weights_shape)
channels = [
{
'weights': [weights],
'trainable': False,
'input_dim': vocabulary_size + 1,
'output_dim': embedding_size,
'name': 'random-embedding-1'
},
{
'weights': [weights],
'trainable': True,
'input_dim': vocabulary_size + 1,
'output_dim': embedding_size,
'name': 'random-embedding-2'
}
]
windows = [
{
'filters': 100,
'kernel_size': 3,
'activation': 'relu',
'name': '3-grams'
},
{
'filters': 100,
'kernel_size': 4,
'activation': 'relu',
'name': '4-grams'
},
{
'filters': 100,
'kernel_size': 5,
'activation': 'relu',
'name': '5-grams'
}
]
from kim2014convolutional import Model
model = Model(channels=channels,
windows=windows,
sentence_length=37,
num_classes=6,
dropout_rate=0.5,
maxnorm_value=3,
classifier_activation='softmax',
include_top=True,
name='CNN-multichannel')
model.summary()
```
This package provides a simple implementation of the models proposed in
the paper:
> Kim, Y. (2014). Convolutional neural networks for sentence classification. arXiv preprint arXiv:1408.5882.
## Installation
This package depends on the [Keras](https://keras.io/) library. This
means you will need to install a backend library in order to use this
module. Take a look to [Keras installation](https://keras.io/#installation)
to get more information.
After having installed the backend of yout choice, you just need to
install this package using [pip](https://pypi.org/):
pip install kim2014convolutional
## Usage
This package only provides a single model. To get detailed information
on the parameters the model accepts, take a look to the documentation
included with the module class.
Here is a complete example of instantiation of the `CNN-multichannel`
model proposed in the original paper using two channel of randomly
initialized word embeddings:
```python
import numpy as np
import numpy.random as rng
vocabulary_size = 10000
embedding_size = 300
value = np.sqrt(6/embedding_size)
weights_shape = (vocabulary_size+1, embedding_size)
weights = rng.uniform(low=-value, high=value, size=weights_shape)
channels = [
{
'weights': [weights],
'trainable': False,
'input_dim': vocabulary_size + 1,
'output_dim': embedding_size,
'name': 'random-embedding-1'
},
{
'weights': [weights],
'trainable': True,
'input_dim': vocabulary_size + 1,
'output_dim': embedding_size,
'name': 'random-embedding-2'
}
]
windows = [
{
'filters': 100,
'kernel_size': 3,
'activation': 'relu',
'name': '3-grams'
},
{
'filters': 100,
'kernel_size': 4,
'activation': 'relu',
'name': '4-grams'
},
{
'filters': 100,
'kernel_size': 5,
'activation': 'relu',
'name': '5-grams'
}
]
from kim2014convolutional import Model
model = Model(channels=channels,
windows=windows,
sentence_length=37,
num_classes=6,
dropout_rate=0.5,
maxnorm_value=3,
classifier_activation='softmax',
include_top=True,
name='CNN-multichannel')
model.summary()
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for kim2014convolutional-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4cccd512a0206ca086d0e020d13a4b08b24850e6dc143bf22529e04d8d0120a |
|
MD5 | b6468ddfd3f5f4db30a161ba97f27001 |
|
BLAKE2b-256 | e99d127502c308ae7c72c1f4f735f91a2b447ecbf2f86f7e447b7dc421410477 |
Close
Hashes for kim2014convolutional-0.2.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fa8c0e986c29226ab8d079623515b47a366da0f059b8eb3082e4e0fc17f88dc |
|
MD5 | ace825b7aafc3cc0da7d7c6664ceb00d |
|
BLAKE2b-256 | f919f92bea9615674e651ee6f3a932d0c9136273a9a033a080838c90ce738ba3 |