Skip to content

chore!(train): データセットを分割して一部で評価するようにする #110

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

Merged
merged 12 commits into from
May 1, 2025

Conversation

sevenc-nanashi
Copy link
Member

内容

trainのデータセットを分割して一部で評価するようにします。

関連 Issue

スクリーンショット・動画など

(なし)

その他

(なし)

@Hiroshiba
Copy link
Member

Hiroshiba commented Apr 28, 2025

こちらは今どういう状態でしょうか 👀
コミット履歴見る感じレビューしても大丈夫だったり・・・?
(どっちもお見合い状態になっているともったいないので聞いてみた次第です! 🙏 )

@sevenc-nanashi
Copy link
Member Author

コミットだけしてレビューリクエストを出し忘れる -> あ、ここリファクタできそう...って感じでした。
もうレビューして大丈夫のはずです。

@sevenc-nanashi sevenc-nanashi requested a review from Copilot April 28, 2025 12:12
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the training process by splitting the original training dataset into distinct training and test subsets for mid-training evaluation. Key changes include:

  • Splitting the training dataset into train and test datasets using torch.utils.data.random_split.
  • Adding a new test data loader and evaluator for performing test evaluations alongside the existing evaluation process.
  • Updating configuration files (Python and YAML) to support the test_ratio parameter.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

File Description
train/src/train.py Introduces dataset splitting and a separate test evaluator/dataloader.
train/src/config.py Adds the test_ratio configuration parameter.
train/config/example.yml Updates example configuration to include test_ratio.
train/config/dummy.yml Updates dummy configuration to include test_ratio.

@@ -278,6 +285,12 @@ def train():
collate_fn=partial(collate_fn, device=device),
drop_last=True,
)
test_dl = DataLoader(
Copy link
Member

Choose a reason for hiding this comment

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

(このプルリクエストに関係ないのですが)

_dl、なかなか問題ありそうな名前ですね 😇
ここは定義だから問題ないけど、使ってるとこでディープラーニングと勘違いしそう。

Comment on lines 361 to 371
def calculate_bleu(
label: str,
model: Model,
evaluator: Evaluator,
epoch: int,
writer: SummaryWriter,
) -> Tensor:
eval_bleu = evaluator.evaluate(model)
writer.add_scalar(f"BLEU/{label}", eval_bleu, epoch)
print(f"Epoch {epoch} {label} BLEU: {eval_bleu}")
return eval_bleu
Copy link
Member

@Hiroshiba Hiroshiba Apr 29, 2025

Choose a reason for hiding this comment

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

calculate_lossは値を返さないのにこっちは値を返しているの、不揃いだなーと感じました!

calculateは値を返すのが正しいと思います。
そしてadd_scalarするのはちょっと関心が違いそう。

calculate_bleuwrite_bleuに分けるとかですかねぇ。(write_bleuという名前が良いのか若干しっくり来ないけど・・・)
まあ少なくとも今の関数名と関数の形はちょっと変そう!

Copy link
Member Author

Choose a reason for hiding this comment

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

write_scalarという関数にしましたが、かといってwriteにしてはprintもしてるし...(commit...?)

Copy link
Member

@Hiroshiba Hiroshiba Apr 30, 2025

Choose a reason for hiding this comment

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

logが良いかなーと思いましたが、対数とかぶるんですよねー。。。

と思ってChatGPTに聞いてみたらreportを進められました!!良さそう!!
https://chatgpt.com/share/681241d8-e34c-8008-a909-7911abde0150
こういう時わりと AI 君いいの出してくれる印象あるので、活用してみると幅広がるかもです!!
(Copilot君に聞くとかなり便利なはず)

Copy link
Member Author

Choose a reason for hiding this comment

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

report_scalarにしました。

@Hiroshiba Hiroshiba requested a review from Copilot April 30, 2025 15:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the training script to split the training dataset into training and test portions and evaluates the model on both during training. Key changes include:

  • Refactoring dataset creation with a new prepare_datasets function that splits the dataset using a test_ratio.
  • Adding a dedicated test DataLoader and corresponding evaluator to calculate test metrics.
  • Updating configuration files to include the test_ratio parameter.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

File Description
train/src/train.py Implements dataset splitting, adds test DataLoader/evaluator, and updates loss/metric logging.
train/src/config.py Adds the new test_ratio config field.
train/config/example.yml Documents the new test_ratio parameter.
train/config/dummy.yml Updates dummy config to include test_ratio.
Comments suppressed due to low confidence (1)

train/src/train.py:312

  • Verify that the RAdamScheduleFree optimizer supports an eval() mode as typical PyTorch optimizers do not. If not, removing or replacing this call might prevent potential runtime errors.
        optimizer.eval()

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

LGTM!!

関数の名前だけ参考になれば!

@sevenc-nanashi
Copy link
Member Author

マージします。

@sevenc-nanashi sevenc-nanashi enabled auto-merge May 1, 2025 01:53
@sevenc-nanashi sevenc-nanashi added this pull request to the merge queue May 1, 2025
Merged via the queue into VOICEVOX:main with commit eba693f May 1, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants