From 16212e289c92544b5c800300db7a168ee3ae8aec Mon Sep 17 00:00:00 2001 From: Taras Savchyn <30748114+trsvchn@users.noreply.github.com> Date: Tue, 20 Apr 2021 00:51:56 +0300 Subject: [PATCH 1/2] Making Text classification template similar to Image Classification (#92) * Fix template sidebar * Code style --- templates/text_classification/_sidebar.py | 107 +++++++++++----------- 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/templates/text_classification/_sidebar.py b/templates/text_classification/_sidebar.py index cbbc77db..03a1b1e0 100644 --- a/templates/text_classification/_sidebar.py +++ b/templates/text_classification/_sidebar.py @@ -18,63 +18,66 @@ def get_configs() -> dict: config["eval_epoch_length"] = None default_none_options(config) - st.header("Transformer") + with st.beta_expander("Text Classification Template Configurations", expanded=True): + st.info("Names in the parenthesis are variable names used in the generated code.") - st.subheader("Model Options") - config["model"] = st.selectbox( - "Model name (from transformers) to setup model, tokenize and config to train (model)", - options=["bert-base-uncased"], - ) - config["model_dir"] = st.text_input("Cache directory to download the pretrained model (model_dir)", value="./") - config["tokenizer_dir"] = st.text_input("Tokenizer cache directory (tokenizer_dir)", value="./tokenizer") - config["num_classes"] = st.number_input( - "Number of target classes. Default, 1 (binary classification) (num_classes)", min_value=0, value=1 - ) - config["max_length"] = st.number_input( - "Maximum number of tokens for the inputs to the transformer model (max_length)", min_value=1, value=256 - ) - config["dropout"] = st.number_input( - "Dropout probability (dropout)", min_value=0.0, max_value=1.0, value=0.3, format="%f" - ) - config["n_fc"] = st.number_input( - "Number of neurons in the last fully connected layer (n_fc)", min_value=1, value=768 - ) - st.markdown("---") + st.subheader("Model Options") + config["model"] = st.selectbox( + "Model name (from transformers) to setup model, tokenize and config to train (model)", + options=["bert-base-uncased"], + ) + config["model_dir"] = st.text_input("Cache directory to download the pretrained model (model_dir)", value="./") + config["tokenizer_dir"] = st.text_input("Tokenizer cache directory (tokenizer_dir)", value="./tokenizer") + config["num_classes"] = st.number_input( + "Number of target classes. Default, 1 (binary classification) (num_classes)", min_value=0, value=1 + ) + config["max_length"] = st.number_input( + "Maximum number of tokens for the inputs to the transformer model (max_length)", min_value=1, value=256 + ) + config["dropout"] = st.number_input( + "Dropout probability (dropout)", min_value=0.0, max_value=1.0, value=0.3, format="%f" + ) + config["n_fc"] = st.number_input( + "Number of neurons in the last fully connected layer (n_fc)", min_value=1, value=768 + ) + st.markdown("---") - st.subheader("Dataset Options") - config["data_dir"] = st.text_input("Dataset cache directory (data_dir)", value="./") - st.markdown("---") + st.subheader("Dataset Options") + config["data_dir"] = st.text_input("Dataset cache directory (data_dir)", value="./") + st.markdown("---") - st.subheader("DataLoader Options") - config["batch_size"] = st.number_input("Total batch size (batch_size)", min_value=1, value=4) - config["num_workers"] = st.number_input("Number of workers in the data loader (num_workers)", min_value=1, value=2) - st.markdown("---") + st.subheader("DataLoader Options") + config["batch_size"] = st.number_input("Total batch size (batch_size)", min_value=1, value=4) + config["num_workers"] = st.number_input( + "Number of workers in the data loader (num_workers)", min_value=1, value=2 + ) + st.markdown("---") - st.subheader("Optimizer Options") - config["learning_rate"] = st.number_input( - "Peak of piecewise linear learning rate scheduler", min_value=0.0, value=5e-5, format="%e" - ) - config["weight_decay"] = st.number_input("Weight decay", min_value=0.0, value=0.01, format="%f") - st.markdown("---") + st.subheader("Optimizer Options") + config["learning_rate"] = st.number_input( + "Peak of piecewise linear learning rate scheduler", min_value=0.0, value=5e-5, format="%e" + ) + config["weight_decay"] = st.number_input("Weight decay", min_value=0.0, value=0.01, format="%f") + st.markdown("---") - st.subheader("Training Options") - config["max_epochs"] = st.number_input("Number of epochs to train the model", min_value=1, value=3) - config["num_warmup_epochs"] = st.number_input( - "Number of warm-up epochs before learning rate decay", min_value=0, value=0 - ) - config["validate_every"] = st.number_input( - "Run model's validation every validate_every epochs", min_value=0, value=1 - ) - config["checkpoint_every"] = st.number_input( - "Store training checkpoint every checkpoint_every iterations", min_value=0, value=1000 - ) - config["log_every_iters"] = st.number_input( - "Argument to log batch loss every log_every_iters iterations. 0 to disable it", min_value=0, value=15 - ) - st.markdown("---") + st.subheader("Training Options") + config["max_epochs"] = st.number_input("Number of epochs to train the model", min_value=1, value=3) + config["num_warmup_epochs"] = st.number_input( + "Number of warm-up epochs before learning rate decay", min_value=0, value=0 + ) + config["validate_every"] = st.number_input( + "Run model's validation every validate_every epochs", min_value=0, value=1 + ) + config["checkpoint_every"] = st.number_input( + "Store training checkpoint every checkpoint_every iterations", min_value=0, value=1000 + ) + config["log_every_iters"] = st.number_input( + "Argument to log batch loss every log_every_iters iterations. 0 to disable it", min_value=0, value=15 + ) + st.markdown("---") - distributed_options(config) - ignite_handlers_options(config) - ignite_loggers_options(config) + distributed_options(config) + ignite_handlers_options(config) + ignite_loggers_options(config) return config From cf46da94baad1c2538eadee2eaed2f5316f042ca Mon Sep 17 00:00:00 2001 From: vfdev Date: Tue, 20 Apr 2021 00:13:43 +0200 Subject: [PATCH 2/2] [skip ci] updated contributing and readme (#93) * [skip ci] updated contributing * [skip ci] Updated readme --- CONTRIBUTING.md | 6 +++--- README.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 51495175..a4a56708 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,7 +71,7 @@ This allows to run and debug the generated templates from the `dist` folder. ## Pull Request Guidelines -- Checkout a topic branch from a base branch, e.g. `master`. +- Checkout a topic branch from a base branch, e.g. `dev`. - If adding a new template: @@ -120,6 +120,6 @@ Now you can get the latest development into your forked repository with this: ```sh git fetch --all --prune -git checkout master -git merge upstream/master +git checkout dev +git merge upstream/dev ``` diff --git a/README.md b/README.md index 8b4f5867..4d49e448 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Streamlit App][streamlit-img]][streamlit-url] [![ci][gha-img]][gha-url] -[![Preview App][aws-img]][aws-url] + # Code Generator @@ -24,8 +24,8 @@ Development of this project is supported by NumFOCUS Small Development Grant. We [BSD 3-Clause](LICENSE) -[aws-img]: https://badgen.net/badge/%20/Deployed%20master%20version/ee4c2c?label= -[aws-url]: http://pytorch-ignite-code-generator-dev.eu-west-3.elasticbeanstalk.com/ + + [gha-img]: https://github.com/pytorch-ignite/code-generator/actions/workflows/ci.yml/badge.svg [gha-url]: https://github.com/pytorch-ignite/code-generator/actions/workflows/ci.yml [streamlit-img]: https://static.streamlit.io/badges/streamlit_badge_black_white.svg