You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@singa.apache.org by GitBox <gi...@apache.org> on 2020/06/14 02:53:07 UTC
[GitHub] [singa] dcslin opened a new pull request #733: add imdb sentiment model
dcslin opened a new pull request #733:
URL: https://github.com/apache/singa/pull/733
added imdb sentiment binary classification model, self-contained data preparation scripts, baseline model
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] chrishkchris commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
chrishkchris commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643791102
I took a look at your cudnn rnn function:
you transpose the input so that "inputs has shape of {sequence length, batch size, feature size}"
Meanwhile, when I read the cudnn API
https://docs.nvidia.com/deeplearning/sdk/cudnn-api/index.html#cudnnRNNForwardInference
the description of x is:
_xDesc
Input. An array of seqLength fully packed tensor descriptors. Each descriptor in the array should have three dimensions that describe the input data format to one recurrent iteration (one descriptor per RNN time-step). **The first dimension (batch size)** of the tensors may decrease from iteration n to iteration n+1 but may not increase. Each tensor descriptor must have the same second dimension (RNN input vector length, inputSize). The third dimension of each tensor should be 1. Input data are expected to be arranged in the column-major order so strides in xDesc should be set as follows:_
See the highlighted text in the above description. The first dimension is batch size?
It is a bit confusing for me, so I am not sure what should be the input shape. I suggest checking all those input output format if you don't have further idea for debug.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] nudles merged pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
nudles merged pull request #733:
URL: https://github.com/apache/singa/pull/733
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] XJDKC commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
XJDKC commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-644583418
> > And I found that the calculation of dw is not based on dy in the back propagation function of the rnn operator. Is this correct?
>
> hi from the cudnn api, dy is not used when getting dw, I think cudnn internals used the `reserve_space` for keeping `dy` from `backward dx`
Got it. Thanks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] lgtm-com[bot] commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-649920579
This pull request **introduces 2 alerts** when merging bffd9b7412263f1fb6c566cc15a735d245ed4487 into ea873fe8714b12788666db0fdb5a4810b5f3a435 - [view on LGTM.com](https://lgtm.com/projects/g/apache/singa/rev/pr-ce8bb3e910a09ed09d6db1e7bc2f194b9f2342bd)
**new alerts:**
* 1 for Duplication in regular expression character class
* 1 for Unused local variable
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] lgtm-com[bot] commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643745699
This pull request **introduces 2 alerts** when merging c4aeeb87d784c0351dea6d2e1d9de1b438f57626 into 042b0810b2ae0553a3fe81683a532fe1e0b1a2b3 - [view on LGTM.com](https://lgtm.com/projects/g/apache/singa/rev/pr-08d03564d4bb0f8b8f1cf234e3c3e17908a881c6)
**new alerts:**
* 1 for Duplication in regular expression character class
* 1 for Unused local variable
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] dcslin commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
dcslin commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643872776
> I took a look at your cudnn rnn function:
> https://github.com/apache/singa/blob/dev/python/singa/layer.py#L1506
> you transpose the input so that "inputs has shape of {sequence length, batch size, feature size}"
>
> Meanwhile, when I read the cudnn API `cudnnRNNForwardInference()`
> https://docs.nvidia.com/deeplearning/sdk/cudnn-api/index.html#cudnnRNNForwardInference
> the description of x is:
>
> _xDesc Input. An array of seqLength fully packed tensor descriptors. Each descriptor in the array should have three dimensions that describe the input data format to one recurrent iteration (one descriptor per RNN time-step). **The first dimension (batch size)** of the tensors may decrease from iteration n to iteration n+1 but may not increase. Each tensor descriptor must have the same second dimension (RNN input vector length, inputSize). The third dimension of each tensor should be 1. Input data are expected to be arranged in the column-major order so strides in xDesc should be set as follows:_
>
> See the highlighted text in the above description. The first dimension is batch size?
>
> It is a bit confusing for me, so I am not sure what should be the input shape. I suggest checking all those input output format if you don't have further idea for debug.
thank you for the review, this part is indeed confusing.
### in the general case of cudnn api
so we need to pass a list of xDesc into cudnn
which means xDesc0, xDesc1, xDesc2, xDesc3, ... xDescn
each xDesc has shape of {bs, input}
means xDesc0{bs1, input}, xDesc2{bs2, input}, xDesc3{bs3, input} ... xDescn{bsn, input}
and the total length of these xDesc0, xDesc1, xDesc2, xDesc3, xDescn is seq length
### in the special case assuming all the `bs` are the same
for data pointer, singa tensor x, we will have shape {seq_length, bs, input}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] chrishkchris commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
chrishkchris commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643768843
@dcslin
In your code, even you use the same train dataset for evaluation, the accuracy will drop from 0.985 (train) to 0.867 (eval) using the same train dataset (test dataset eval accuracy is 0.504 in this case).
Seems that (i) the inference rountine have some problem with cudnnRNNForwardInference, or (ii) the train model cannot generalize (only can remember the train data but cannot generalize)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] dcslin commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
dcslin commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-646635254
Currently it is working:
```
# PYTHONPATH=./build/python python3 examples/rnn/imdb_train.py -h
usage: imdb_train.py [-h] [-m MAX_EPOCH] [-b BS] [-l LR] [-i DEVICE_ID]
[--mode MODE] [--return-sequences RETURN_SEQUENCES]
[--bidirectional BIDIRECTIONAL] [--num-layers NUM_LAYERS]
optional arguments:
-h, --help show this help message and exit
-m MAX_EPOCH, --max-epoch MAX_EPOCH
maximum epochs
-b BS, --batch-size BS
batch size
-l LR, --learning-rate LR
initial learning rate
-i DEVICE_ID, --device-id DEVICE_ID
which GPU to use
--mode MODE relu, tanh, lstm, gru
--return-sequences RETURN_SEQUENCES
return sequences
--bidirectional BIDIRECTIONAL
bidirectional lstm
--num-layers NUM_LAYERS
num layers
# PYTHONPATH=./build/python python3 examples/rnn/imdb_train.py
epoch 0 loss [0.71537286]; acc 0.546
epoch 1 loss [0.65785825]; acc 0.604
epoch 2 loss [0.6347779]; acc 0.636
epoch 3 loss [0.61257607]; acc 0.661
epoch 4 loss [0.5874256]; acc 0.685
eval acc 0.594
```
Implemented the "Ex" versions of api, which is better with supporting on masking and row major(no need transpose). But encountering CUDNN_STATUS_EXECUTION_FAILED error
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] dcslin commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
dcslin commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643710366
Current problem: accuracy stucks at 50%, have tried to use different data source, implement mirror model in keras using same dataset, parameter tunning(much thanks to chris for the advice). The loss is very similar to keras impl, but the accuracy would not increase. Currently investigating lstm layer.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] chrishkchris edited a comment on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
chrishkchris edited a comment on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643791102
I took a look at your cudnn rnn function:
https://github.com/apache/singa/blob/dev/python/singa/layer.py#L1506
you transpose the input so that "inputs has shape of {sequence length, batch size, feature size}"
Meanwhile, when I read the cudnn API `cudnnRNNForwardInference()`
https://docs.nvidia.com/deeplearning/sdk/cudnn-api/index.html#cudnnRNNForwardInference
the description of x is:
_xDesc
Input. An array of seqLength fully packed tensor descriptors. Each descriptor in the array should have three dimensions that describe the input data format to one recurrent iteration (one descriptor per RNN time-step). **The first dimension (batch size)** of the tensors may decrease from iteration n to iteration n+1 but may not increase. Each tensor descriptor must have the same second dimension (RNN input vector length, inputSize). The third dimension of each tensor should be 1. Input data are expected to be arranged in the column-major order so strides in xDesc should be set as follows:_
See the highlighted text in the above description. The first dimension is batch size?
It is a bit confusing for me, so I am not sure what should be the input shape. I suggest checking all those input output format if you don't have further idea for debug.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] dcslin commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
dcslin commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-644517619
> And I found that the calculation of dw is not based on dy in the back propagation function of the rnn operator. Is this correct?
hi from the cudnn api, dy is not used when getting dw, I think cudnn internals used the `reserve_space` for keeping `dy` from `backward dx`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] chrishkchris edited a comment on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
chrishkchris edited a comment on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-644518262
> > And I found that the calculation of dw is not based on dy in the back propagation function of the rnn operator. Is this correct?
>
> hi from the cudnn api, dy is not used when getting dw, I think cudnn internals used the `reserve_space` for keeping `dy` from `backward dx`
This is the API
https://docs.nvidia.com/deeplearning/sdk/cudnn-api/index.html#cudnnRNNBackwardWeights
It needs x, y, hx, reserveSpace
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] chrishkchris commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
chrishkchris commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643715038
FYI.
It's strange. With some tuning the loss and accuracy aren't unchanged, but the loss and accuracy progressing VERY SLOW
```
epoch 0 loss [0.69790334]; acc 0.497
epoch 1 loss [0.69498737]; acc 0.500
epoch 2 loss [0.69426662]; acc 0.501
epoch 3 loss [0.69382397]; acc 0.503
epoch 4 loss [0.69360678]; acc 0.501
epoch 5 loss [0.69345892]; acc 0.503
epoch 6 loss [0.6933501]; acc 0.503
epoch 7 loss [0.69326572]; acc 0.503
epoch 8 loss [0.6932142]; acc 0.503
epoch 9 loss [0.69316711]; acc 0.504
epoch 10 loss [0.69312428]; acc 0.504
epoch 11 loss [0.69309989]; acc 0.503
epoch 12 loss [0.6930678]; acc 0.505
epoch 13 loss [0.69304936]; acc 0.505
epoch 14 loss [0.69301656]; acc 0.506
epoch 15 loss [0.69300658]; acc 0.506
epoch 16 loss [0.69298803]; acc 0.506
epoch 17 loss [0.69297332]; acc 0.507
epoch 18 loss [0.69294707]; acc 0.507
epoch 19 loss [0.69291532]; acc 0.508
epoch 20 loss [0.69291264]; acc 0.509
epoch 21 loss [0.69289198]; acc 0.508
epoch 22 loss [0.69287588]; acc 0.510
epoch 23 loss [0.69286742]; acc 0.508
epoch 24 loss [0.69285808]; acc 0.509
epoch 25 loss [0.69283317]; acc 0.509
epoch 26 loss [0.6927981]; acc 0.510
epoch 27 loss [0.69279238]; acc 0.511
epoch 28 loss [0.69278047]; acc 0.510
epoch 29 loss [0.69275107]; acc 0.511
epoch 30 loss [0.69272761]; acc 0.511
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] dcslin commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
dcslin commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643770454
> @dcslin
> In your code, even you use the same train dataset for evaluation, the accuracy will drop from 0.985 (train) to 0.867 (eval) using the same train dataset (test dataset eval accuracy is 0.504 in this case).
>
> Seems that (i) the inference rountine have some problem with cudnnRNNForwardInference, or (ii) the train model cannot generalize (only can remember the train data but cannot generalize)
even though i used m.train() for "inference" on testing set, still the accuracy is low (0.5)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] chrishkchris commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
chrishkchris commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-644518262
> > And I found that the calculation of dw is not based on dy in the back propagation function of the rnn operator. Is this correct?
>
> hi from the cudnn api, dy is not used when getting dw, I think cudnn internals used the `reserve_space` for keeping `dy` from `backward dx`
This one? https://docs.nvidia.com/deeplearning/sdk/cudnn-api/index.html#cudnnRNNBackwardWeights
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] lgtm-com[bot] commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643710638
This pull request **introduces 2 alerts** when merging 0969b61e037e8902c79596e82cad266648714059 into 042b0810b2ae0553a3fe81683a532fe1e0b1a2b3 - [view on LGTM.com](https://lgtm.com/projects/g/apache/singa/rev/pr-2913089b53d9819ca7ff7808bdf5f555390c396b)
**new alerts:**
* 1 for Duplication in regular expression character class
* 1 for Unused local variable
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] XJDKC commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
XJDKC commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643887562
And I found that the calculation of dw is not based on dy in the back propagation function of the rnn operator. Is this correct?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] dcslin commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
dcslin commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-649330572
Ex version testings are added. currently only allow `seq_major`/`time_major` but the user is not affected.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] dcslin commented on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
dcslin commented on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643760154
thank you @chrishkchris ,
i could get this with param:
```
bs = 32
seq_limit = 50
embed_size = 300
hid = 128
max_epoch=20
m.set_opt(opt.SGD(0.01, 0.9))
m.lstm.W.gaussian(0,0.2)
```
result:
```
epoch 0 loss [0.6986327]; acc 0.499
epoch 1 loss [0.6938767]; acc 0.507
epoch 2 loss [0.6930023]; acc 0.512
epoch 3 loss [0.69218916]; acc 0.520
epoch 4 loss [0.6913854]; acc 0.527
epoch 5 loss [0.69030344]; acc 0.532
epoch 6 loss [0.68892217]; acc 0.536
epoch 7 loss [0.6871515]; acc 0.544
epoch 8 loss [0.6844753]; acc 0.552
epoch 9 loss [0.68085307]; acc 0.563
epoch 10 loss [0.6761205]; acc 0.573
epoch 11 loss [0.67002034]; acc 0.585
epoch 12 loss [0.6628929]; acc 0.598
epoch 13 loss [0.6532587]; acc 0.609
epoch 14 loss [0.6417091]; acc 0.628
epoch 15 loss [0.6291587]; acc 0.642
epoch 16 loss [0.6140896]; acc 0.657
epoch 17 loss [0.60099155]; acc 0.670
epoch 18 loss [0.5853541]; acc 0.685
epoch 19 loss [0.5661139]; acc 0.703
```
but I really could not make testing >0.5 with various config
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [singa] chrishkchris edited a comment on pull request #733: add imdb sentiment model
Posted by GitBox <gi...@apache.org>.
chrishkchris edited a comment on pull request #733:
URL: https://github.com/apache/singa/pull/733#issuecomment-643791102
I took a look at your cudnn rnn function:
https://github.com/apache/singa/blob/dev/python/singa/layer.py#L1506
you transpose the input so that "inputs has shape of {sequence length, batch size, feature size}"
Meanwhile, when I read the cudnn API
https://docs.nvidia.com/deeplearning/sdk/cudnn-api/index.html#cudnnRNNForwardInference
the description of x is:
_xDesc
Input. An array of seqLength fully packed tensor descriptors. Each descriptor in the array should have three dimensions that describe the input data format to one recurrent iteration (one descriptor per RNN time-step). **The first dimension (batch size)** of the tensors may decrease from iteration n to iteration n+1 but may not increase. Each tensor descriptor must have the same second dimension (RNN input vector length, inputSize). The third dimension of each tensor should be 1. Input data are expected to be arranged in the column-major order so strides in xDesc should be set as follows:_
See the highlighted text in the above description. The first dimension is batch size?
It is a bit confusing for me, so I am not sure what should be the input shape. I suggest checking all those input output format if you don't have further idea for debug.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org