{"id":17339747,"url":"https://github.com/parap1uie-s/alternate_sg","last_synced_at":"2025-03-27T08:24:46.700Z","repository":{"id":156897455,"uuid":"172742366","full_name":"parap1uie-s/alternate_sg","owner":"parap1uie-s","description":"Code for 'alternate synthetic gradient'","archived":false,"fork":false,"pushed_at":"2019-02-26T15:54:08.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T13:24:50.254Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parap1uie-s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-26T15:53:15.000Z","updated_at":"2020-06-29T11:01:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"b4998677-4b2a-49ad-a410-d6f03f5f45ee","html_url":"https://github.com/parap1uie-s/alternate_sg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parap1uie-s%2Falternate_sg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parap1uie-s%2Falternate_sg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parap1uie-s%2Falternate_sg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parap1uie-s%2Falternate_sg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parap1uie-s","download_url":"https://codeload.github.com/parap1uie-s/alternate_sg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245807627,"owners_count":20675576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T15:42:56.309Z","updated_at":"2025-03-27T08:24:46.675Z","avatar_url":"https://github.com/parap1uie-s.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# alternate_sg\n\nThis repository contains the code used for the paper: Alternating Synthetic and Real Gradients for Neural Language Modeling\n\n## Software Requirements\n\n- python 3+\n\n- PyTorch 0.4\n\n- \\* [PyTorch-QRNN 0.2.1 ](https://github.com/salesforce/pytorch-qrnn)\n\n\\* Bug fixed, replace site-packages/torchqrnn/forget_mult.py with forget_mult.py after qrnn installed.\n\n## Experiments\n\nThe element-wise DNI module interact with base module by sending gradients to the hidden states of base module at truncated point.\n\n### Word level Penn Treebank (PTB) with QRNN(base) and QRNN(DNI)\n\n- DNI\n\n`python3.6 -u main.py --model QRNN --batch_size 20 --clip 0.2 --wdrop 0.1 --nhid 1550 --nlayers 4 --emsize 400 --dropouth 0.3 --seed 42 --dropouti 0.4 --optimizer adam --lr 1e-3 --cuda --bptt=200 --epochs=320 --expname=ptbword_qrnn_sg --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --whenswitch=2 --use_sg --sgtype=QRNN`\n\n- DNI with Restart base == 160\n\n`python3.6 -u main.py --model QRNN --batch_size 20 --clip 0.2 --wdrop 0.1 --nhid 1550 --nlayers 4 --emsize 400 --dropouth 0.3 --seed 42 --dropouti 0.4 --optimizer adam --lr 1e-3 --cuda --bptt=200 --epochs=320 --expname=ptbword_qrnn_sg_restart_rb160 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --whenswitch=2 --use_sg --sgtype=QRNN --restart_base 160 320 --restart_lr`\n\n- DNI with Restart base == 5\n\n`python3.6 -u main.py --model QRNN --batch_size 20 --clip 0.2 --wdrop 0.1 --nhid 1550 --nlayers 4 --emsize 400 --dropouth 0.3 --seed 42 --dropouti 0.4 --optimizer adam --lr 1e-3 --cuda --bptt=200 --epochs=320 --expname=ptbword_qrnn_sg_restart_rb5 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --whenswitch=2 --use_sg --sgtype=QRNN --restart_base=5 --restart_lr`\n\n- Alternating DNI with Restart base == 160\n\n`python3.6 -u main.py --model QRNN --batch_size 20 --clip 0.2 --wdrop 0.1 --nhid 1550 --nlayers 4 --emsize 400 --dropouth 0.3 --seed 42 --dropouti 0.4 --optimizer adam --lr 1e-3 --cuda --bptt=200 --epochs=320 --expname=ptbword_qrnn_mixture_rb160 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --use_sg --sgtype=QRNN --mixture --restart_base 160 320 --restart_lr`\n\n- Alternating DNI with Restart base == 5\n\n`python3.6 -u main.py --model QRNN --batch_size 20 --clip 0.2 --wdrop 0.1 --nhid 1550 --nlayers 4 --emsize 400 --dropouth 0.3 --seed 42 --dropouti 0.4 --optimizer adam --lr 1e-3 --cuda --bptt=200 --epochs=320 --expname=ptbword_qrnn_mixture_rb5 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --use_sg --sgtype=QRNN --mixture --restart_base=5 --restart_lr`\n\n### Word level WikiText-2 (WT2) with QRNN(base) and QRNN(DNI)\n\n- DNI\n\n`python3.6 -u main.py --cuda --bptt=200 --data data/wikitext-2 --clip 0.25 --dropouti 0.4 --dropouth 0.2 --nhid 1550 --nlayers 4 --seed 42 --model QRNN --wdrop 0.1 --batch_size 20 --optimizer adam --lr 1e-3 --expname=wikiword_qrnn_sg --epochs 320 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --whenswitch=2 --use_sg --sgtype=QRNN`\n\n- DNI with Restart base == 160\n\n`python3.6 -u main.py --cuda --bptt=200 --data data/wikitext-2 --clip 0.25 --dropouti 0.4 --dropouth 0.2 --nhid 1550 --nlayers 4 --seed 42 --model QRNN --wdrop 0.1 --batch_size 20 --optimizer adam --lr 1e-3 --expname=wikiword_qrnn_sg_restart_rb160 --epochs 320 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --whenswitch=2 --use_sg --sgtype=QRNN --restart_base 160 320 --restart_lr`\n\n- DNI with Restart base == 5\n\n`python3.6 -u main.py --cuda --bptt=200 --data data/wikitext-2 --clip 0.25 --dropouti 0.4 --dropouth 0.2 --nhid 1550 --nlayers 4 --seed 42 --model QRNN --wdrop 0.1 --batch_size 20 --optimizer adam --lr 1e-3 --expname=wikiword_qrnn_sg_restart_rb5 --epochs 320 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --whenswitch=2 --use_sg --sgtype=QRNN --restart_base=5 --restart_lr`\n\n- Alternating DNI with Restart base == 160\n\n`python3.6 -u main.py --cuda --bptt=200 --data data/wikitext-2 --clip 0.25 --dropouti 0.4 --dropouth 0.2 --nhid 1550 --nlayers 4 --seed 42 --model QRNN --wdrop 0.1 --batch_size 20 --optimizer adam --lr 1e-3 --expname=wikiword_qrnn_mixture_rb160 --epochs 320 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --use_sg --sgtype=QRNN --mixture --restart_base 160 320 --restart_lr --whenswitch=2`\n\n- Alternating DNI with Restart base == 5\n\n`python3.6 -u main.py --cuda --bptt=200 --data data/wikitext-2 --clip 0.25 --dropouti 0.4 --dropouth 0.2 --nhid 1550 --nlayers 4 --seed 42 --model QRNN --wdrop 0.1 --batch_size 20 --optimizer adam --lr 1e-3 --expname=wikiword_qrnn_mixture_rb5 --epochs 320 --sg_hidden_num=50 --sg_nlayers=1 --sg_dropout=0.1 --use_sg --sgtype=QRNN --mixture --restart_base=5 --restart_lr --whenswitch=2`\n\n## hyper parameters\n\n### ptbword\n| name  | BPTT | DNI |\n|:---:|:---:|:---:|\n| lr  | 1e-3 | 1e-3 |\n| optimizer  | adam | adam |\n| BPTT length | 200  | 200 |\n| base model type  | QRNN | QRNN |\n| base neurons per layer  | 1550 | 1550 |\n| base layers  | 4 | 4 |\n| random seed  | 42 | 42 |\n| batch size  | 20 | 20 |\n| DNI model type  | N/A | QRNN |\n| DNI neurons / layer(s)  | N/A | 50/1 |\n\n### wikiword-2\n| name  | BPTT | DNI |\n|:---:|:---:|:---:|\n| lr  | 1e-3 | 1e-3 |\n| optimizer  | adam | adam |\n| BPTT length | 200  | 200 |\n| base model type  | QRNN | QRNN |\n| base neurons per layer  | 1550 | 1550 |\n| base layers  | 4 | 4 |\n| random seed  | 42 | 42 |\n| batch size  | 20 | 20 |\n| DNI model type  | N/A | QRNN |\n| DNI neurons / layer(s)  | N/A | 50/1 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparap1uie-s%2Falternate_sg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparap1uie-s%2Falternate_sg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparap1uie-s%2Falternate_sg/lists"}