250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- 지마켓
- tomoto
- (깃)git bash
- spring MVC(모델2)방식
- mysql
- db
- 자바
- test
- RESFUL
- java
- 幼稚园杀手(유치원킬러)
- jsp 파일 설정
- Gmarket
- 과학백과사전
- r
- lda
- Websocket
- 토픽추출
- 이력서
- 크롤링
- Python
- oracle
- 파이썬
- pytorch
- word2vec
- 게시판 만들기
- 네이버뉴스
- Topics
- 코사인 유사도
- 방식으로 텍스트
Archives
- Today
- Total
무회blog
200814,test bert 001 본문
In [1]:
# conda install -c conda-forge ipywidgets
In [2]:
from fast_bert.data_cls import BertDataBunch
DATA_PATH = './../Downloads/fastai/fast-bert-1.8.0/sample_data/imdb_movie_reviews/data/'
LABEL_PATH = './../Downloads/fastai/fast-bert-1.8.0/sample_data/imdb_movie_reviews/label/'
OUTPUT_DIR = './../Downloads/fastai/fast-bert-1.8.0/sample_data/imdb_movie_reviews/output/'
databunch = BertDataBunch(DATA_PATH, LABEL_PATH,
tokenizer='bert-base-uncased',
train_file='train_sample.csv',
val_file='val_sample.csv',
label_file='labels.csv',
text_col='text',
label_col='label',
batch_size_per_gpu=16,
max_seq_length=512,
multi_gpu=True,
multi_label=False,
model_type='bert')
In [4]:
databunch
# Create a Learner Object
from fast_bert.learner_cls import BertLearner
from fast_bert.metrics import accuracy
import logging
import torch
logger = logging.getLogger()
device_cuda = torch.device("cuda")
metrics = [{'name': 'accuracy', 'function': accuracy}]
learner = BertLearner.from_pretrained_model(
databunch,
pretrained_path='bert-base-uncased',
metrics=metrics,
device=device_cuda,
logger=logger,
output_dir=OUTPUT_DIR,
finetuned_wgts_path=None,
warmup_steps=500,
multi_gpu=False,
is_fp16=True,
multi_label=False,
logging_steps=50)
In [ ]:
# 3. Find the optimal learning rate
learner.lr_find(start_lr=1e-5,optimizer_type='lamb')
'Python > TA' 카테고리의 다른 글
python: pytorch, model , train 시키기 , (0) | 2020.08.13 |
---|---|
python: pytorch, 질의응답관련 , bert 사용 (0) | 2020.08.13 |
python: pytorch,transformer , pipline , 提问解答사용해보기 (0) | 2020.08.13 |
python: pytorch,Bert, 로 토큰나이징 하기 (0) | 2020.08.13 |
Comments