Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

At text classification example #945

Open
wants to merge 89 commits into
base: master
Choose a base branch
from

Conversation

atuzhykov
Copy link

What changes were proposed in this pull request?

(Please fill in changes proposed in this fix)

How was this patch tested?

(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)

Please review
https://github.com/eclipse/deeplearning4j/blob/master/CONTRIBUTING.md before opening a pull request.

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
l2 1e-6 > 1e-3

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
l2 1e-3 > 1e-6

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
atuzhykov and others added 27 commits March 5, 2020 01:03
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
)

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
…r1e-4

Signed-off-by: atuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Copy link
Contributor

@AlexDBlack AlexDBlack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a few minor improvements to make.
Can we also make a backup of the branch, then flatten + sign on this branch as described here: https://deeplearning4j.org/eclipse-contributors

Otherwise I'm happy with this 👍

* As far model is predisposed to overfitting we also add l2 regularization and dropout for certain layers.
* To prepare reviews we use BertIterator, which is MultiDataSetIterator for training BERT (Transformer) models.
* We congigure BertIterator for supervised sequence classification:
* 0. As tokenizer we use BertWordPieceTokenizerFactory with provided BERT BASE UNCASED vocabulary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's improve this slightly, add another line under 0.:
BertIterator and BertWordPieceTokenizer implement the Word Piece sub-word tokenization algorithm, with a vocabulary size of 30522 tokens.

int listenerFrequency = 20;
net.setListeners(new StatsListener(statsStorage, listenerFrequency), new ScoreIterationListener(50));
//Attach the StatsStorage instance to the UI: this allows the contents of the StatsStorage to be visualized
uiServer.attach(statsStorage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's comment out the UI by default, as it adds some overhead (slows down training a bit). Users can uncomment it if they want to run it with UI. That would look like this:

        /*
        //Uncomment this section to run the example with the user interface
        UIServer uiServer = UIServer.getInstance();

        //Configure where the network information (gradients, activations, score vs. time etc) is to be stored
        //Then add the StatsListener to collect this information from the network, as it trains
        StatsStorage statsStorage = new FileStatsStorage(new File(System.getProperty("java.io.tmpdir"), "ui-stats-" + System.currentTimeMillis() + ".dl4j"));
        int listenerFrequency = 20;
        net.setListeners(new StatsListener(statsStorage, listenerFrequency), new ScoreIterationListener(50));
        //Attach the StatsStorage instance to the UI: this allows the contents of the StatsStorage to be visualized
        uiServer.attach(statsStorage);
        */
        
        net.setListeners(new ScoreIterationListener(50));

net.fit(train);

// Get and print accuracy, precision, recall & F1 and confusion matrix
Evaluation eval = net.doEvaluation(test, new Evaluation[]{new Evaluation()})[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For MultiLayerNetwork, we can use net.evaluate(test)

pom.xml Outdated
@@ -28,7 +28,7 @@
<properties>
<!-- Change the nd4j.backend property to nd4j-cuda-9.2-platform,nd4j-cuda-10.0-platform or nd4j-cuda-10.1-platform to use CUDA GPUs -->
<nd4j.backend>nd4j-native-platform</nd4j.backend>
<!-- <nd4j.backend>nd4j-cuda-10.2-platform</nd4j.backend>-->
<!-- <nd4j.backend>nd4j-cuda-10.0-platform</nd4j.backend>-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave this commented out with 10.2

Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
…ation class

Signed-off-by: Andrii Tuzhykov <andrewtuzhykov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants