-
Notifications
You must be signed in to change notification settings - Fork 2
Add requirements.txt #4
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
Open
YeRyeongLee
wants to merge
8
commits into
level1_sst
Choose a base branch
from
yeryeong
base: level1_sst
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fee5157
test again
YeRyeongLee 9efa82d
delete test.txt
YeRyeongLee 26a2dc2
add requirements.txt
YeRyeongLee 761167e
modify train.py
YeRyeongLee a7eabe7
add scatterplot to train.py
YeRyeongLee abbacf7
add inference.py
YeRyeongLee f3b60db
add save_config to train.py
YeRyeongLee 4c597dc
add seed_everything to inference.py
YeRyeongLee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import argparse | ||
|
|
||
| import pandas as pd | ||
|
|
||
| from tqdm.auto import tqdm | ||
|
|
||
| import transformers | ||
| import torch | ||
| import torchmetrics | ||
| import pytorch_lightning as pl | ||
|
|
||
|
|
||
| ### TODO : path, filename 정해지면 수정 | ||
| # from PATH import CUSTOMDATAMODULE as DataModule | ||
| # from PATH import CUSTOMMODEL as Model | ||
| # from PATH import CUSTOMTRAINER as Trainer | ||
| # from PATH import CUSTOMPREPROCESS as preprocess | ||
|
|
||
|
|
||
| # fix random seeds for reproducibility | ||
| SEED = 123 | ||
| seed_everything(SEED, workers=True) # pl seed | ||
|
|
||
|
|
||
|
|
||
| def inference(args): | ||
| ### TODO : preprocess 함수도 인자로 넘겼으면.. | ||
| datamodule = DataModule(args.model_name, | ||
| args.batch_size, args.shuffle, | ||
| args.train_path, args.dev_path, | ||
| args.test_path, args.predict_path) | ||
|
|
||
| model = Model(args.model_name, | ||
| args.learning_rate) | ||
|
|
||
| trainer = Trainer(gpus=1, | ||
| max_epochs=arg.max_epoch, | ||
| log_every_n_steps=1) | ||
|
|
||
| # Inference | ||
| model = torch.load(args.best_model_path) | ||
| predictions = trainer.predict(model=model, | ||
| datamodule=datamodule) | ||
|
|
||
| predictions = list(round(float(i), 1) for i in torch.cat(predictions)) | ||
|
|
||
| output = pd.read_csv('./data/sample_submission.csv') | ||
| output['target'] = predictions | ||
|
|
||
| output_name = args.best_model_path[:-3] + '.csv' | ||
| output.to_csv('output.csv', index=False) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| ### TODO : best model의 config값 불러와서 argument로 지정 | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument('--best_model_path', default='model.pt') | ||
|
|
||
| args = parser.parse_args(args=[]) | ||
|
|
||
| inference(args) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| pyYAML==5.4.1 | ||
| pytorch-lightning==1.7.3 | ||
| tqdm==4.64.1 | ||
| torchmetrics==0.10.0 | ||
| torch==1.12.1 | ||
| transformers==4.21.2 | ||
| numpy==1.20.3 | ||
| pandas==1.5.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저희 베이스라인의 train.py를 조금 수정해서 넣었습니다.
모델을 저장할 때 ./save/model/.pt 로 저장되게 했고,
modelname = 모델성능 + 베이스모델이름 + 저장시각 + 돌린사람으로 설정했어요~