Trax 문서·API — 튜토리얼부터 API 인덱스

Trax 문서·API

Trax를 본격적으로 쓰려면 레이어·모델·데이터·추론을 어떻게 맞물리는지 보여주는 튜토리얼부터 시작하는 게 좋아요. ReadTheDocs 문서는 노트북 기반 튜토리얼과 API 레퍼런스를 한곳에 모아요.

출처: https://trax-ml.readthedocs.io/en/latest/

문서 구조

  • Trax Quick Intro — 사전학습 Transformer 실행, 기능 소개, walkthrough
  • Trax Layers Intro — 레이어 개념, 입출력, 새 레이어 클래스 정의, 테스트·디버깅
  • Using Trax with TensorFlow NumPy and Keras — TF NumPy와 사용, Keras로 변환, 배포용 모델 내보내기
  • Trax API — 전체 API 레퍼런스

유용한 API 참조

모델 실행 후

학습 후엔 모델을 레이어처럼 그냥 호출해서 결과를 얻어요.

example_input = next(eval_batches_stream)[0][0]
example_input_str = trax.data.detokenize(example_input, vocab_file='en_8k.subword')
print(f'example input_str: {example_input_str}')
sentiment_log_probs = model(example_input[None, :])  # 배치 차원 추가
print(f'Model returned sentiment probabilities: {np.exp(sentiment_log_probs)}')
Model returned sentiment probabilities: [[3.984500e-04 9.996014e-01]]

더 알아보기