import{s as Ye,o as Ae,n as Ue}from"../chunks/scheduler.56730f09.js";import{S as Fe,i as Ne,g as r,s as o,u as $,A as Se,h as p,f as t,c as i,j as w,v,y as g,k as u,o as c,a as s,w as b,d as j,t as T,x as J}from"../chunks/index.ba464511.js";import{T as xe}from"../chunks/Tip.70442610.js";import{Y as Ze}from"../chunks/Youtube.7b20230c.js";import{I as te}from"../chunks/IconCopyLink.89bde88e.js";import{C as V}from"../chunks/CodeBlock.2302fd0d.js";import{D as Le}from"../chunks/DocNotebookDropdown.68fd8653.js";import{F as He,M as Ge}from"../chunks/Markdown.6303afae.js";function Qe(Wt){let m,k=`사전 훈련된 가중치 중 일부가 사용되지 않고 일부 가중치가 무작위로 표시된다는 경고가 표시됩니다.
걱정마세요. 이것은 올바른 동작입니다! 사전 학습된 BERT 모델의 헤드는 폐기되고 무작위로 초기화된 분류 헤드로 대체됩니다. 이제 사전 학습된 모델의 지식으로 시퀀스 분류 작업을 위한 새로운 모델 헤드를 미세 튜닝 합니다.`;return{c(){m=r("p"),m.textContent=k},l(h){m=p(h,"P",{"data-svelte-h":!0}),g(m)!=="svelte-133r2kc"&&(m.textContent=k)},m(h,_){s(h,m,_)},p:Ue,d(h){h&&t(m)}}}function Pe(Wt){let m,k,h,_,C,Z,Ht,z,Yt="파이토치 Trainer로 훈련하기",it,Jt,ee="🤗 Transformers는 🤗 Transformers 모델 훈련에 최적화된 <code>Trainer</code> 클래스를 제공하여 훈련 루프를 직접 작성하지 않고도 쉽게 훈련을 시작할 수 있습니다. <code>Trainer</code> API는 로깅(logging), 경사 누적(gradient accumulation), 혼합 정밀도(mixed precision) 등 다양한 훈련 옵션과 기능을 지원합니다.",K,F,ht='먼저 모델을 가져오고 예상되는 레이블 수를 지정합니다. Yelp 리뷰 <a href="https://huggingface.co/datasets/yelp_review_full#data-fields" rel="nofollow">데이터셋 카드</a>에서 5개의 레이블이 있음을 알 수 있습니다:',at,lt,$t,H,Qt,x,mt,ct,W,xt,dt,vt="하이퍼파라미터 훈련",kt,At,Rt="다음으로 정할 수 있는 모든 하이퍼파라미터와 다양한 훈련 옵션을 활성화하기 위한 플래그를 포함하는 <code>TrainingArguments</code> 클래스를 생성합니다.",D,O,_t='이 튜토리얼에서는 기본 훈련 <a href="https://huggingface.co/docs/transformers/main_classes/trainer#transformers.TrainingArguments" rel="nofollow">하이퍼파라미터</a>로 시작하지만, 자유롭게 실험하여 여러분들에게 맞는 최적의 설정을 찾을 수 있습니다.',se,tt,ft="훈련에서 체크포인트(checkpoints)를 저장할 위치를 지정합니다:",Gt,et,N,R,I,Ct,nt,bt,Xt,ut="평가 하기",It,S,rt=`<code>Trainer</code>는 훈련 중에 모델 성능을 자동으로 평가하지 않습니다. 평가 지표를 계산하고 보고할 함수를 <code>Trainer</code>에 전달해야 합니다.
<a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">🤗 Evaluate</a> 라이브러리는 <a href="https://huggingface.co/spaces/evaluate-metric/accuracy" rel="nofollow"><code>evaluate.load</code></a> 함수로 로드할 수 있는 간단한 <code>accuracy</code>함수를 제공합니다 (자세한 내용은 <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">둘러보기</a>를 참조하세요):`,jt,L,Et,st,pt="<code>metric</code>에서 <code>compute</code>를 호출하여 예측의 정확도를 계산합니다. 예측을 <code>compute</code>에 전달하기 전에 예측을 로짓으로 변환해야 합니다(모든 🤗 Transformers 모델은 로짓으로 반환한다는 점을 기억하세요):",Mt,X,Tt,E,Kt="미세 튜닝 중에 평가 지표를 모니터링하려면 훈련 인수에 <code>evaluation_strategy</code> 파라미터를 지정하여 각 에폭이 끝날 때 평가 지표를 확인할 수 있습니다:",Ft,G,le,ot,U,Nt,Y,Bt,Q,A="훈련 하기",St,B,Pt="모델, 훈련 인수, 훈련 및 테스트 데이터셋, 평가 함수가 포함된 <code>Trainer</code> 객체를 만듭니다:",Zt,P,ae,q,yt="그리고 <code>train()</code>을 호출하여 모델을 미세 튜닝합니다:",Ut,l,d;return m=new Ze({props:{id:"nvBXf7s7vTI"}}),Z=new te({}),lt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`,wrap:!1}}),H=new xe({props:{$$slots:{default:[Qe]},$$scope:{ctx:Wt}}}),W=new te({}),et=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTBBJTBBdHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKG91dHB1dF9kaXIlM0QlMjJ0ZXN0X3RyYWluZXIlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;test_trainer&quot;</span>)`,wrap:!1}}),nt=new te({}),L=new V({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMmFjY3VyYWN5JTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)`,wrap:!1}}),X=new V({props:{code:"ZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMkMlMjBsYWJlbHMlMjAlM0QlMjBldmFsX3ByZWQlMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyMCUzRCUyMG5wLmFyZ21heChsb2dpdHMlMkMlMjBheGlzJTNELTEpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWV0cmljLmNvbXB1dGUocHJlZGljdGlvbnMlM0RwcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0RsYWJlbHMp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    logits, labels = eval_pred
<span class="hljs-meta">... </span>    predictions = np.argmax(logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> metric.compute(predictions=predictions, references=labels)`,wrap:!1}}),G=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTJDJTIwVHJhaW5lciUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBUcmFpbmluZ0FyZ3VtZW50cyhvdXRwdXRfZGlyJTNEJTIydGVzdF90cmFpbmVyJTIyJTJDJTIwZXZhbHVhdGlvbl9zdHJhdGVneSUzRCUyMmVwb2NoJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;test_trainer&quot;</span>, evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>)`,wrap:!1}}),Y=new te({}),P=new V({props:{code:"dHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHNtYWxsX3RyYWluX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=small_train_dataset,
<span class="hljs-meta">... </span>    eval_dataset=small_eval_dataset,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)`,wrap:!1}}),l=new V({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()',wrap:!1}}),{c(){$(m.$$.fragment),k=o(),h=r("h2"),_=r("a"),C=r("span"),$(Z.$$.fragment),Ht=o(),z=r("span"),z.textContent=Yt,it=o(),Jt=r("p"),Jt.innerHTML=ee,K=o(),F=r("p"),F.innerHTML=ht,at=o(),$(lt.$$.fragment),$t=o(),$(H.$$.fragment),Qt=o(),x=r("h3"),mt=r("a"),ct=r("span"),$(W.$$.fragment),xt=o(),dt=r("span"),dt.textContent=vt,kt=o(),At=r("p"),At.innerHTML=Rt,D=o(),O=r("p"),O.innerHTML=_t,se=o(),tt=r("p"),tt.textContent=ft,Gt=o(),$(et.$$.fragment),N=o(),R=r("h3"),I=r("a"),Ct=r("span"),$(nt.$$.fragment),bt=o(),Xt=r("span"),Xt.textContent=ut,It=o(),S=r("p"),S.innerHTML=rt,jt=o(),$(L.$$.fragment),Et=o(),st=r("p"),st.innerHTML=pt,Mt=o(),$(X.$$.fragment),Tt=o(),E=r("p"),E.innerHTML=Kt,Ft=o(),$(G.$$.fragment),le=o(),ot=r("h3"),U=r("a"),Nt=r("span"),$(Y.$$.fragment),Bt=o(),Q=r("span"),Q.textContent=A,St=o(),B=r("p"),B.innerHTML=Pt,Zt=o(),$(P.$$.fragment),ae=o(),q=r("p"),q.innerHTML=yt,Ut=o(),$(l.$$.fragment),this.h()},l(a){v(m.$$.fragment,a),k=i(a),h=p(a,"H2",{class:!0});var y=w(h);_=p(y,"A",{id:!0,class:!0,href:!0});var gt=w(_);C=p(gt,"SPAN",{});var Vt=w(C);v(Z.$$.fragment,Vt),Vt.forEach(t),gt.forEach(t),Ht=i(y),z=p(y,"SPAN",{"data-svelte-h":!0}),g(z)!=="svelte-xux3je"&&(z.textContent=Yt),y.forEach(t),it=i(a),Jt=p(a,"P",{"data-svelte-h":!0}),g(Jt)!=="svelte-1a30hsl"&&(Jt.innerHTML=ee),K=i(a),F=p(a,"P",{"data-svelte-h":!0}),g(F)!=="svelte-vv5j33"&&(F.innerHTML=ht),at=i(a),v(lt.$$.fragment,a),$t=i(a),v(H.$$.fragment,a),Qt=i(a),x=p(a,"H3",{class:!0});var wt=w(x);mt=p(wt,"A",{id:!0,class:!0,href:!0});var Dt=w(mt);ct=p(Dt,"SPAN",{});var Lt=w(ct);v(W.$$.fragment,Lt),Lt.forEach(t),Dt.forEach(t),xt=i(wt),dt=p(wt,"SPAN",{"data-svelte-h":!0}),g(dt)!=="svelte-1pmq875"&&(dt.textContent=vt),wt.forEach(t),kt=i(a),At=p(a,"P",{"data-svelte-h":!0}),g(At)!=="svelte-1sl91ao"&&(At.innerHTML=Rt),D=i(a),O=p(a,"P",{"data-svelte-h":!0}),g(O)!=="svelte-17gf6c"&&(O.innerHTML=_t),se=i(a),tt=p(a,"P",{"data-svelte-h":!0}),g(tt)!=="svelte-3gh4w5"&&(tt.textContent=ft),Gt=i(a),v(et.$$.fragment,a),N=i(a),R=p(a,"H3",{class:!0});var zt=w(R);I=p(zt,"A",{id:!0,class:!0,href:!0});var re=w(I);Ct=p(re,"SPAN",{});var ie=w(Ct);v(nt.$$.fragment,ie),ie.forEach(t),re.forEach(t),bt=i(zt),Xt=p(zt,"SPAN",{"data-svelte-h":!0}),g(Xt)!=="svelte-1nunm40"&&(Xt.textContent=ut),zt.forEach(t),It=i(a),S=p(a,"P",{"data-svelte-h":!0}),g(S)!=="svelte-1ofd291"&&(S.innerHTML=rt),jt=i(a),v(L.$$.fragment,a),Et=i(a),st=p(a,"P",{"data-svelte-h":!0}),g(st)!=="svelte-fpot8d"&&(st.innerHTML=pt),Mt=i(a),v(X.$$.fragment,a),Tt=i(a),E=p(a,"P",{"data-svelte-h":!0}),g(E)!=="svelte-b8mk68"&&(E.innerHTML=Kt),Ft=i(a),v(G.$$.fragment,a),le=i(a),ot=p(a,"H3",{class:!0});var qt=w(ot);U=p(qt,"A",{id:!0,class:!0,href:!0});var ne=w(U);Nt=p(ne,"SPAN",{});var he=w(Nt);v(Y.$$.fragment,he),he.forEach(t),ne.forEach(t),Bt=i(qt),Q=p(qt,"SPAN",{"data-svelte-h":!0}),g(Q)!=="svelte-4fwkgz"&&(Q.textContent=A),qt.forEach(t),St=i(a),B=p(a,"P",{"data-svelte-h":!0}),g(B)!=="svelte-w01mtl"&&(B.innerHTML=Pt),Zt=i(a),v(P.$$.fragment,a),ae=i(a),q=p(a,"P",{"data-svelte-h":!0}),g(q)!=="svelte-xfml58"&&(q.innerHTML=yt),Ut=i(a),v(l.$$.fragment,a),this.h()},h(){u(_,"id","train-with-pytorch-trainer"),u(_,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(_,"href","#train-with-pytorch-trainer"),u(h,"class","relative group"),u(mt,"id","training-hyperparameters"),u(mt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(mt,"href","#training-hyperparameters"),u(x,"class","relative group"),u(I,"id","evaluate"),u(I,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(I,"href","#evaluate"),u(R,"class","relative group"),u(U,"id","trainer"),u(U,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(U,"href","#trainer"),u(ot,"class","relative group")},m(a,y){b(m,a,y),s(a,k,y),s(a,h,y),c(h,_),c(_,C),b(Z,C,null),c(h,Ht),c(h,z),s(a,it,y),s(a,Jt,y),s(a,K,y),s(a,F,y),s(a,at,y),b(lt,a,y),s(a,$t,y),b(H,a,y),s(a,Qt,y),s(a,x,y),c(x,mt),c(mt,ct),b(W,ct,null),c(x,xt),c(x,dt),s(a,kt,y),s(a,At,y),s(a,D,y),s(a,O,y),s(a,se,y),s(a,tt,y),s(a,Gt,y),b(et,a,y),s(a,N,y),s(a,R,y),c(R,I),c(I,Ct),b(nt,Ct,null),c(R,bt),c(R,Xt),s(a,It,y),s(a,S,y),s(a,jt,y),b(L,a,y),s(a,Et,y),s(a,st,y),s(a,Mt,y),b(X,a,y),s(a,Tt,y),s(a,E,y),s(a,Ft,y),b(G,a,y),s(a,le,y),s(a,ot,y),c(ot,U),c(U,Nt),b(Y,Nt,null),c(ot,Bt),c(ot,Q),s(a,St,y),s(a,B,y),s(a,Zt,y),b(P,a,y),s(a,ae,y),s(a,q,y),s(a,Ut,y),b(l,a,y),d=!0},p(a,y){const gt={};y&2&&(gt.$$scope={dirty:y,ctx:a}),H.$set(gt)},i(a){d||(j(m.$$.fragment,a),j(Z.$$.fragment,a),j(lt.$$.fragment,a),j(H.$$.fragment,a),j(W.$$.fragment,a),j(et.$$.fragment,a),j(nt.$$.fragment,a),j(L.$$.fragment,a),j(X.$$.fragment,a),j(G.$$.fragment,a),j(Y.$$.fragment,a),j(P.$$.fragment,a),j(l.$$.fragment,a),d=!0)},o(a){T(m.$$.fragment,a),T(Z.$$.fragment,a),T(lt.$$.fragment,a),T(H.$$.fragment,a),T(W.$$.fragment,a),T(et.$$.fragment,a),T(nt.$$.fragment,a),T(L.$$.fragment,a),T(X.$$.fragment,a),T(G.$$.fragment,a),T(Y.$$.fragment,a),T(P.$$.fragment,a),T(l.$$.fragment,a),d=!1},d(a){a&&(t(k),t(h),t(it),t(Jt),t(K),t(F),t(at),t($t),t(Qt),t(x),t(kt),t(At),t(D),t(O),t(se),t(tt),t(Gt),t(N),t(R),t(It),t(S),t(jt),t(Et),t(st),t(Mt),t(Tt),t(E),t(Ft),t(le),t(ot),t(St),t(B),t(Zt),t(ae),t(q),t(Ut)),J(m,a),J(Z),J(lt,a),J(H,a),J(W),J(et,a),J(nt),J(L,a),J(X,a),J(G,a),J(Y),J(P,a),J(l,a)}}}function qe(Wt){let m,k;return m=new Ge({props:{$$slots:{default:[Pe]},$$scope:{ctx:Wt}}}),{c(){$(m.$$.fragment)},l(h){v(m.$$.fragment,h)},m(h,_){b(m,h,_),k=!0},p(h,_){const C={};_&2&&(C.$$scope={dirty:_,ctx:h}),m.$set(C)},i(h){k||(j(m.$$.fragment,h),k=!0)},o(h){T(m.$$.fragment,h),k=!1},d(h){J(m,h)}}}function Ke(Wt){let m,k=`모델을 <code>compile()</code>할 때 손실 인수를 모델에 전달할 필요가 없습니다!
이 인수를 비워두면 허깅 페이스 모델은 작업과 모델 아키텍처에 적합한 손실을 자동으로 선택합니다.
원한다면 언제든지 직접 손실을 지정하여 이를 재정의할 수 있습니다!`;return{c(){m=r("p"),m.innerHTML=k},l(h){m=p(h,"P",{"data-svelte-h":!0}),g(m)!=="svelte-z0fgk0"&&(m.innerHTML=k)},m(h,_){s(h,m,_)},p:Ue,d(h){h&&t(m)}}}function De(Wt){let m,k,h,_,C,Z,Ht,z,Yt,it,Jt="Keras로 텐서플로우 모델 훈련하기",ee,K,F="Keras API를 사용하여 텐서플로우에서 🤗 Transformers 모델을 훈련할 수도 있습니다!",ht,at,lt,$t,H,Qt,x,mt="Keras용 데이터 로드",ct,W,xt=`Keras API로 🤗 Transformers 모델을 학습시키려면 데이터셋을 Keras가 이해할 수 있는 형식으로 변환해야 합니다.
데이터 세트가 작은 경우, 전체를 NumPy 배열로 변환하여 Keras로 전달하면 됩니다.
더 복잡한 작업을 수행하기 전에 먼저 이 작업을 시도해 보겠습니다.`,dt,vt,kt=`먼저 데이터 세트를 로드합니다. <a href="https://huggingface.co/datasets/glue" rel="nofollow">GLUE 벤치마크</a>의 CoLA 데이터 세트를 사용하겠습니다.
간단한 바이너리 텍스트 분류 작업이므로 지금은 훈련 데이터 분할만 사용합니다.`,At,Rt,D,O,_t="다음으로 토크나이저를 로드하고 데이터를 NumPy 배열로 토큰화합니다. 레이블은 이미 0과 1로 된 리스트이기 때문에 토큰화하지 않고 바로 NumPy 배열로 변환할 수 있습니다!",se,tt,ft,Gt,et='마지막으로 모델을 로드, <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>, <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a>합니다:',N,R,I,Ct,nt,bt,Xt=`이 접근 방식은 소규모 데이터 집합에서는 잘 작동하지만, 대규모 데이터 집합에서는 문제가 될 수 있습니다. 왜 그럴까요?
토큰화된 배열과 레이블을 메모리에 완전히 로드하고 NumPy는 “들쭉날쭉한” 배열을 처리하지 않기 때문에,
모든 토큰화된 샘플을 전체 데이터셋에서 가장 긴 샘플의 길이만큼 패딩해야 합니다. 이렇게 하면 배열이 훨씬 더 커지고 이 패딩 토큰으로 인해 학습 속도도 느려집니다!`,ut,It,S,rt,jt,L,Et,st="데이터를 tf.data.Dataset으로 로드하기",pt,Mt,X=`학습 속도가 느려지는 것을 피하려면 데이터를 <code>tf.data.Dataset</code>으로 로드할 수 있습니다. 원한다면 직접
<code>tf.data</code> 파이프라인을 직접 작성할 수도 있지만, 이 작업을 간편하게 수행하는 수 있는 두 가지 방법이 있습니다:`,Tt,E,Kt=`<li><code>prepare_tf_dataset()</code>: 대부분의 경우 이 방법을 권장합니다. 모델의 메서드이기 때문에 모델을 검사하여 모델 입력으로 사용할 수 있는 열을 자동으로 파악하고
나머지는 버려서 더 단순하고 성능이 좋은 데이터 집합을 만들 수 있습니다.</li> <li><code>to_tf_dataset</code>: 이 방법은 좀 더 낮은 수준이며, 포함할 ‘열’과 ‘레이블’을 정확히 지정하여
데이터셋을 생성하는 방법을 정확히 제어하고 싶을 때 유용하며, 포함할 ‘columns’과 ‘label_cols’을 정확히 지정할 수 있습니다.</li>`,Ft,G,le="<code>prepare_tf_dataset()</code>을 사용하려면 먼저 다음 코드 샘플과 같이 토크나이저 출력을 데이터 세트에 열로 추가해야 합니다:",ot,U,Nt,Y,Bt=`허깅 페이스 데이터셋은 기본적으로 디스크에 저장되므로 메모리 사용량을 늘리지 않는다는 점을 기억하세요!
열이 추가되면 데이터셋에서 배치를 스트리밍하고 각 배치에 패딩을 추가할 수 있으므로 전체 데이터셋에 패딩을 추가하는 것보다 패딩 토큰의 수를 크게 줄일 수 있습니다.`,Q,A,St,B,Pt=`위의 코드 샘플에서는 배치가 로드될 때 올바르게 패딩할 수 있도록 <code>prepare_tf_dataset</code>에 토크나이저를 전달해야 합니다.
데이터셋의 모든 샘플 길이가 같고 패딩이 필요하지 않은 경우 이 인수를 건너뛸 수 있습니다.
샘플을 채우는 것보다 더 복잡한 작업(예: 마스킹된 언어의 토큰 손상 모델링)을 수행하기 위해 토큰을 손상시켜야 하는 경우,
<code>collate_fn</code> 인수를 사용하여 샘플 목록을 배치로 변환하고 원하는 전처리를 적용할 함수를 전달할 수 있습니다.
<a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">예시</a> 또는
<a href="https://huggingface.co/docs/transformers/notebooks" rel="nofollow">노트북</a>을 참조하여 이 접근 방식이 실제로 작동하는 모습을 확인하세요.`,Zt,P,ae="<code>tf.data.Dataset</code>을 생성한 후에는 이전과 마찬가지로 모델을 컴파일하고 훈련(fit)할 수 있습니다:",q,yt,Ut;return h=new Ze({props:{id:"rnTGBy2ax1c"}}),z=new te({}),H=new te({}),Rt=new V({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJnbHVlJTIyJTJDJTIwJTIyY29sYSUyMiklMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldCU1QiUyMnRyYWluJTIyJTVEJTIwJTIwJTIzJTIwSnVzdCUyMHRha2UlMjB0aGUlMjB0cmFpbmluZyUyMHNwbGl0JTIwZm9yJTIwbm93",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

dataset = load_dataset(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;cola&quot;</span>)
dataset = dataset[<span class="hljs-string">&quot;train&quot;</span>]  <span class="hljs-comment"># Just take the training split for now</span>`,wrap:!1}}),tt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBdG9rZW5pemVkX2RhdGElMjAlM0QlMjB0b2tlbml6ZXIoZGF0YXNldCU1QiUyMnNlbnRlbmNlJTIyJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJucCUyMiUyQyUyMHBhZGRpbmclM0RUcnVlKSUwQSUyMyUyMFRva2VuaXplciUyMHJldHVybnMlMjBhJTIwQmF0Y2hFbmNvZGluZyUyQyUyMGJ1dCUyMHdlJTIwY29udmVydCUyMHRoYXQlMjB0byUyMGElMjBkaWN0JTIwZm9yJTIwS2VyYXMlMEF0b2tlbml6ZWRfZGF0YSUyMCUzRCUyMGRpY3QodG9rZW5pemVkX2RhdGEpJTBBJTBBbGFiZWxzJTIwJTNEJTIwbnAuYXJyYXkoZGF0YXNldCU1QiUyMmxhYmVsJTIyJTVEKSUyMCUyMCUyMyUyMExhYmVsJTIwaXMlMjBhbHJlYWR5JTIwYW4lMjBhcnJheSUyMG9mJTIwMCUyMGFuZCUyMDE=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
tokenized_data = tokenizer(dataset[<span class="hljs-string">&quot;sentence&quot;</span>], return_tensors=<span class="hljs-string">&quot;np&quot;</span>, padding=<span class="hljs-literal">True</span>)
<span class="hljs-comment"># Tokenizer returns a BatchEncoding, but we convert that to a dict for Keras</span>
tokenized_data = <span class="hljs-built_in">dict</span>(tokenized_data)

labels = np.array(dataset[<span class="hljs-string">&quot;label&quot;</span>])  <span class="hljs-comment"># Label is already an array of 0 and 1</span>`,wrap:!1}}),R=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQWZyb20lMjB0ZW5zb3JmbG93LmtlcmFzLm9wdGltaXplcnMlMjBpbXBvcnQlMjBBZGFtJTBBJTBBJTIzJTIwTG9hZCUyMGFuZCUyMGNvbXBpbGUlMjBvdXIlMjBtb2RlbCUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTIzJTIwTG93ZXIlMjBsZWFybmluZyUyMHJhdGVzJTIwYXJlJTIwb2Z0ZW4lMjBiZXR0ZXIlMjBmb3IlMjBmaW5lLXR1bmluZyUyMHRyYW5zZm9ybWVycyUwQW1vZGVsLmNvbXBpbGUob3B0aW1pemVyJTNEQWRhbSgzZS01KSklMEElMEFtb2RlbC5maXQodG9rZW5pemVkX2RhdGElMkMlMjBsYWJlbHMp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification
<span class="hljs-keyword">from</span> tensorflow.keras.optimizers <span class="hljs-keyword">import</span> Adam

<span class="hljs-comment"># Load and compile our model</span>
model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
<span class="hljs-comment"># Lower learning rates are often better for fine-tuning transformers</span>
model.<span class="hljs-built_in">compile</span>(optimizer=Adam(<span class="hljs-number">3e-5</span>))

model.fit(tokenized_data, labels)`,wrap:!1}}),Ct=new xe({props:{$$slots:{default:[Ke]},$$scope:{ctx:Wt}}}),jt=new te({}),U=new V({props:{code:"ZGVmJTIwdG9rZW5pemVfZGF0YXNldChkYXRhKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMEtleXMlMjBvZiUyMHRoZSUyMHJldHVybmVkJTIwZGljdGlvbmFyeSUyMHdpbGwlMjBiZSUyMGFkZGVkJTIwdG8lMjB0aGUlMjBkYXRhc2V0JTIwYXMlMjBjb2x1bW5zJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdG9rZW5pemVyKGRhdGElNUIlMjJ0ZXh0JTIyJTVEKSUwQSUwQSUwQWRhdGFzZXQlMjAlM0QlMjBkYXRhc2V0Lm1hcCh0b2tlbml6ZV9kYXRhc2V0KQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_dataset</span>(<span class="hljs-params">data</span>):
    <span class="hljs-comment"># Keys of the returned dictionary will be added to the dataset as columns</span>
    <span class="hljs-keyword">return</span> tokenizer(data[<span class="hljs-string">&quot;text&quot;</span>])


dataset = dataset.<span class="hljs-built_in">map</span>(tokenize_dataset)`,wrap:!1}}),A=new V({props:{code:"dGZfZGF0YXNldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldChkYXRhc2V0JTJDJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTIwc2h1ZmZsZSUzRFRydWUlMkMlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_dataset = model.prepare_tf_dataset(dataset, batch_size=<span class="hljs-number">16</span>, shuffle=<span class="hljs-literal">True</span>, tokenizer=tokenizer)',wrap:!1}}),yt=new V({props:{code:"bW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RBZGFtKDNlLTUpKSUwQSUwQW1vZGVsLmZpdCh0Zl9kYXRhc2V0KQ==",highlighted:`model.<span class="hljs-built_in">compile</span>(optimizer=Adam(<span class="hljs-number">3e-5</span>))

model.fit(tf_dataset)`,wrap:!1}}),{c(){m=r("a"),k=o(),$(h.$$.fragment),_=o(),C=r("h2"),Z=r("a"),Ht=r("span"),$(z.$$.fragment),Yt=o(),it=r("span"),it.textContent=Jt,ee=o(),K=r("p"),K.textContent=F,ht=o(),at=r("h3"),lt=r("a"),$t=r("span"),$(H.$$.fragment),Qt=o(),x=r("span"),x.textContent=mt,ct=o(),W=r("p"),W.textContent=xt,dt=o(),vt=r("p"),vt.innerHTML=kt,At=o(),$(Rt.$$.fragment),D=o(),O=r("p"),O.textContent=_t,se=o(),$(tt.$$.fragment),ft=o(),Gt=r("p"),Gt.innerHTML=et,N=o(),$(R.$$.fragment),I=o(),$(Ct.$$.fragment),nt=o(),bt=r("p"),bt.textContent=Xt,ut=o(),It=r("h3"),S=r("a"),rt=r("span"),$(jt.$$.fragment),L=o(),Et=r("span"),Et.textContent=st,pt=o(),Mt=r("p"),Mt.innerHTML=X,Tt=o(),E=r("ul"),E.innerHTML=Kt,Ft=o(),G=r("p"),G.innerHTML=le,ot=o(),$(U.$$.fragment),Nt=o(),Y=r("p"),Y.textContent=Bt,Q=o(),$(A.$$.fragment),St=o(),B=r("p"),B.innerHTML=Pt,Zt=o(),P=r("p"),P.innerHTML=ae,q=o(),$(yt.$$.fragment),this.h()},l(l){m=p(l,"A",{id:!0}),w(m).forEach(t),k=i(l),v(h.$$.fragment,l),_=i(l),C=p(l,"H2",{class:!0});var d=w(C);Z=p(d,"A",{id:!0,class:!0,href:!0});var a=w(Z);Ht=p(a,"SPAN",{});var y=w(Ht);v(z.$$.fragment,y),y.forEach(t),a.forEach(t),Yt=i(d),it=p(d,"SPAN",{"data-svelte-h":!0}),g(it)!=="svelte-uqfh4n"&&(it.textContent=Jt),d.forEach(t),ee=i(l),K=p(l,"P",{"data-svelte-h":!0}),g(K)!=="svelte-ze9716"&&(K.textContent=F),ht=i(l),at=p(l,"H3",{class:!0});var gt=w(at);lt=p(gt,"A",{id:!0,class:!0,href:!0});var Vt=w(lt);$t=p(Vt,"SPAN",{});var wt=w($t);v(H.$$.fragment,wt),wt.forEach(t),Vt.forEach(t),Qt=i(gt),x=p(gt,"SPAN",{"data-svelte-h":!0}),g(x)!=="svelte-1c89e88"&&(x.textContent=mt),gt.forEach(t),ct=i(l),W=p(l,"P",{"data-svelte-h":!0}),g(W)!=="svelte-15pnkld"&&(W.textContent=xt),dt=i(l),vt=p(l,"P",{"data-svelte-h":!0}),g(vt)!=="svelte-1u2iume"&&(vt.innerHTML=kt),At=i(l),v(Rt.$$.fragment,l),D=i(l),O=p(l,"P",{"data-svelte-h":!0}),g(O)!=="svelte-kduu5a"&&(O.textContent=_t),se=i(l),v(tt.$$.fragment,l),ft=i(l),Gt=p(l,"P",{"data-svelte-h":!0}),g(Gt)!=="svelte-1mtm6sq"&&(Gt.innerHTML=et),N=i(l),v(R.$$.fragment,l),I=i(l),v(Ct.$$.fragment,l),nt=i(l),bt=p(l,"P",{"data-svelte-h":!0}),g(bt)!=="svelte-1ggdj2"&&(bt.textContent=Xt),ut=i(l),It=p(l,"H3",{class:!0});var Dt=w(It);S=p(Dt,"A",{id:!0,class:!0,href:!0});var Lt=w(S);rt=p(Lt,"SPAN",{});var zt=w(rt);v(jt.$$.fragment,zt),zt.forEach(t),Lt.forEach(t),L=i(Dt),Et=p(Dt,"SPAN",{"data-svelte-h":!0}),g(Et)!=="svelte-p9esx1"&&(Et.textContent=st),Dt.forEach(t),pt=i(l),Mt=p(l,"P",{"data-svelte-h":!0}),g(Mt)!=="svelte-5ru8h1"&&(Mt.innerHTML=X),Tt=i(l),E=p(l,"UL",{"data-svelte-h":!0}),g(E)!=="svelte-10w0g1z"&&(E.innerHTML=Kt),Ft=i(l),G=p(l,"P",{"data-svelte-h":!0}),g(G)!=="svelte-10gw6tz"&&(G.innerHTML=le),ot=i(l),v(U.$$.fragment,l),Nt=i(l),Y=p(l,"P",{"data-svelte-h":!0}),g(Y)!=="svelte-10zjmdj"&&(Y.textContent=Bt),Q=i(l),v(A.$$.fragment,l),St=i(l),B=p(l,"P",{"data-svelte-h":!0}),g(B)!=="svelte-1k6j3lz"&&(B.innerHTML=Pt),Zt=i(l),P=p(l,"P",{"data-svelte-h":!0}),g(P)!=="svelte-zwzwju"&&(P.innerHTML=ae),q=i(l),v(yt.$$.fragment,l),this.h()},h(){u(m,"id","keras"),u(Z,"id","train-a-tensorflow-model-with-keras"),u(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Z,"href","#train-a-tensorflow-model-with-keras"),u(C,"class","relative group"),u(lt,"id","loading-data-for-keras"),u(lt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(lt,"href","#loading-data-for-keras"),u(at,"class","relative group"),u(S,"id","loading-data-as-a-tfdatadataset"),u(S,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(S,"href","#loading-data-as-a-tfdatadataset"),u(It,"class","relative group")},m(l,d){s(l,m,d),s(l,k,d),b(h,l,d),s(l,_,d),s(l,C,d),c(C,Z),c(Z,Ht),b(z,Ht,null),c(C,Yt),c(C,it),s(l,ee,d),s(l,K,d),s(l,ht,d),s(l,at,d),c(at,lt),c(lt,$t),b(H,$t,null),c(at,Qt),c(at,x),s(l,ct,d),s(l,W,d),s(l,dt,d),s(l,vt,d),s(l,At,d),b(Rt,l,d),s(l,D,d),s(l,O,d),s(l,se,d),b(tt,l,d),s(l,ft,d),s(l,Gt,d),s(l,N,d),b(R,l,d),s(l,I,d),b(Ct,l,d),s(l,nt,d),s(l,bt,d),s(l,ut,d),s(l,It,d),c(It,S),c(S,rt),b(jt,rt,null),c(It,L),c(It,Et),s(l,pt,d),s(l,Mt,d),s(l,Tt,d),s(l,E,d),s(l,Ft,d),s(l,G,d),s(l,ot,d),b(U,l,d),s(l,Nt,d),s(l,Y,d),s(l,Q,d),b(A,l,d),s(l,St,d),s(l,B,d),s(l,Zt,d),s(l,P,d),s(l,q,d),b(yt,l,d),Ut=!0},p(l,d){const a={};d&2&&(a.$$scope={dirty:d,ctx:l}),Ct.$set(a)},i(l){Ut||(j(h.$$.fragment,l),j(z.$$.fragment,l),j(H.$$.fragment,l),j(Rt.$$.fragment,l),j(tt.$$.fragment,l),j(R.$$.fragment,l),j(Ct.$$.fragment,l),j(jt.$$.fragment,l),j(U.$$.fragment,l),j(A.$$.fragment,l),j(yt.$$.fragment,l),Ut=!0)},o(l){T(h.$$.fragment,l),T(z.$$.fragment,l),T(H.$$.fragment,l),T(Rt.$$.fragment,l),T(tt.$$.fragment,l),T(R.$$.fragment,l),T(Ct.$$.fragment,l),T(jt.$$.fragment,l),T(U.$$.fragment,l),T(A.$$.fragment,l),T(yt.$$.fragment,l),Ut=!1},d(l){l&&(t(m),t(k),t(_),t(C),t(ee),t(K),t(ht),t(at),t(ct),t(W),t(dt),t(vt),t(At),t(D),t(O),t(se),t(ft),t(Gt),t(N),t(I),t(nt),t(bt),t(ut),t(It),t(pt),t(Mt),t(Tt),t(E),t(Ft),t(G),t(ot),t(Nt),t(Y),t(Q),t(St),t(B),t(Zt),t(P),t(q)),J(h,l),J(z),J(H),J(Rt,l),J(tt,l),J(R,l),J(Ct,l),J(jt),J(U,l),J(A,l),J(yt,l)}}}function Oe(Wt){let m,k;return m=new Ge({props:{$$slots:{default:[De]},$$scope:{ctx:Wt}}}),{c(){$(m.$$.fragment)},l(h){v(m.$$.fragment,h)},m(h,_){b(m,h,_),k=!0},p(h,_){const C={};_&2&&(C.$$scope={dirty:_,ctx:h}),m.$set(C)},i(h){k||(j(m.$$.fragment,h),k=!0)},o(h){T(m.$$.fragment,h),k=!1},d(h){J(m,h)}}}function ts(Wt){let m,k='<a href="https://colab.research.google.com/" rel="nofollow">Colaboratory</a> 또는 <a href="https://studiolab.sagemaker.aws/" rel="nofollow">SageMaker StudioLab</a>과 같은 호스팅 노트북이 없는 경우 클라우드 GPU에 무료로 액세스할 수 있습니다.';return{c(){m=r("p"),m.innerHTML=k},l(h){m=p(h,"P",{"data-svelte-h":!0}),g(m)!=="svelte-1ctkiwu"&&(m.innerHTML=k)},m(h,_){s(h,m,_)},p:Ue,d(h){h&&t(m)}}}function es(Wt){let m,k,h,_="<code>Trainer</code>는 훈련 루프를 처리하며 한 줄의 코드로 모델을 미세 조정할 수 있습니다. 직접 훈련 루프를 작성하는 것을 선호하는 사용자의 경우, 기본 PyTorch에서 🤗 Transformers 모델을 미세 조정할 수도 있습니다.",C,Z,Ht="이 시점에서 노트북을 다시 시작하거나 다음 코드를 실행해 메모리를 확보해야 할 수 있습니다:",z,Yt,it,Jt,ee="다음으로, ‘토큰화된 데이터셋’을 수동으로 후처리하여 훈련련에 사용할 수 있도록 준비합니다.",K,F,ht,at,lt="모델이 원시 텍스트를 입력으로 허용하지 않으므로 <code>text</code> 열을 제거합니다:",$t,H,Qt,x,mt,ct="모델에서 인수의 이름이 <code>labels</code>로 지정될 것으로 예상하므로 <code>label</code> 열의 이름을 <code>labels</code>로 변경합니다:",W,xt,dt,vt,kt,At="데이터셋의 형식을 List 대신 PyTorch 텐서를 반환하도록 설정합니다:",Rt,D,O,_t,se="그리고 앞서 표시된 대로 데이터셋의 더 작은 하위 집합을 생성하여 미세 조정 속도를 높입니다:",tt,ft,Gt,et,N,R,I,Ct,nt,bt="DataLoader",Xt,ut,It="훈련 및 테스트 데이터셋에 대한 ‘DataLoader’를 생성하여 데이터 배치를 반복할 수 있습니다:",S,rt,jt,L,Et="예측을 위한 레이블 개수를 사용하여 모델을 로드합니다:",st,pt,Mt,X,Tt,E,Kt,Ft,G,le="옵티마이저 및 학습 속도 스케줄러",ot,U,Nt='옵티마이저와 학습 속도 스케줄러를 생성하여 모델을 미세 조정합니다. 파이토치에서 제공하는 <a href="https://pytorch.org/docs/stable/generated/torch.optim.AdamW.html" rel="nofollow"><code>AdamW</code></a> 옵티마이저를 사용해 보겠습니다:',Y,Bt,Q,A,St="<code>Trainer</code>에서 기본 학습 속도 스케줄러를 생성합니다:",B,Pt,Zt,P,ae="마지막으로, GPU에 액세스할 수 있는 경우 ‘device’를 지정하여 GPU를 사용하도록 합니다. 그렇지 않으면 CPU에서 훈련하며 몇 분이 아닌 몇 시간이 걸릴 수 있습니다.",q,yt,Ut,l,d,a,y="이제 훈련할 준비가 되었습니다! 🥳",gt,Vt,wt,Dt,Lt,zt,re,ie="훈련 루프",qt,ne,he='훈련 진행 상황을 추적하려면 <a href="https://tqdm.github.io/" rel="nofollow">tqdm</a> 라이브러리를 사용하여 트레이닝 단계 수에 진행률 표시줄을 추가하세요:',me,pe,n,f,Ot,oe,ce,we,Me,ve="평가 하기",ye,de,be="<code>Trainer</code>에 평가 함수를 추가한 방법과 마찬가지로, 훈련 루프를 직접 작성할 때도 동일한 작업을 수행해야 합니다. 하지만 이번에는 각 에포크가 끝날 때마다 평가지표를 계산하여 보고하는 대신, <code>add_batch</code>를 사용하여 모든 배치를 누적하고 맨 마지막에 평가지표를 계산합니다.",ge,fe,$e;return m=new Ze({props:{id:"Dh9CL8fyG80"}}),Yt=new V({props:{code:"ZGVsJTIwbW9kZWwlMEFkZWwlMjB0cmFpbmVyJTBBdG9yY2guY3VkYS5lbXB0eV9jYWNoZSgp",highlighted:`<span class="hljs-keyword">del</span> model
<span class="hljs-keyword">del</span> trainer
torch.cuda.empty_cache()`,wrap:!1}}),H=new V({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzLnJlbW92ZV9jb2x1bW5zKCU1QiUyMnRleHQlMjIlNUQp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = tokenized_datasets.remove_columns([<span class="hljs-string">&quot;text&quot;</span>])',wrap:!1}}),xt=new V({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzLnJlbmFtZV9jb2x1bW4oJTIybGFiZWwlMjIlMkMlMjAlMjJsYWJlbHMlMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = tokenized_datasets.rename_column(<span class="hljs-string">&quot;label&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>)',wrap:!1}}),D=new V({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzLnNldF9mb3JtYXQoJTIydG9yY2glMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets.set_format(<span class="hljs-string">&quot;torch&quot;</span>)',wrap:!1}}),ft=new V({props:{code:"c21hbGxfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnNodWZmbGUoc2VlZCUzRDQyKS5zZWxlY3QocmFuZ2UoMTAwMCkpJTBBc21hbGxfZXZhbF9kYXRhc2V0JTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzJTVCJTIydGVzdCUyMiU1RC5zaHVmZmxlKHNlZWQlM0Q0Mikuc2VsZWN0KHJhbmdlKDEwMDApKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>small_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>small_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;test&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))`,wrap:!1}}),I=new te({}),rt=new V({props:{code:"ZnJvbSUyMHRvcmNoLnV0aWxzLmRhdGElMjBpbXBvcnQlMjBEYXRhTG9hZGVyJTBBJTBBdHJhaW5fZGF0YWxvYWRlciUyMCUzRCUyMERhdGFMb2FkZXIoc21hbGxfdHJhaW5fZGF0YXNldCUyQyUyMHNodWZmbGUlM0RUcnVlJTJDJTIwYmF0Y2hfc2l6ZSUzRDgpJTBBZXZhbF9kYXRhbG9hZGVyJTIwJTNEJTIwRGF0YUxvYWRlcihzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMjBiYXRjaF9zaXplJTNEOCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader

<span class="hljs-meta">&gt;&gt;&gt; </span>train_dataloader = DataLoader(small_train_dataset, shuffle=<span class="hljs-literal">True</span>, batch_size=<span class="hljs-number">8</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>eval_dataloader = DataLoader(small_eval_dataset, batch_size=<span class="hljs-number">8</span>)`,wrap:!1}}),pt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`,wrap:!1}}),Kt=new te({}),Bt=new V({props:{code:"ZnJvbSUyMHRvcmNoLm9wdGltJTIwaW1wb3J0JTIwQWRhbVclMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtVyhtb2RlbC5wYXJhbWV0ZXJzKCklMkMlMjBsciUzRDVlLTUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.optim <span class="hljs-keyword">import</span> AdamW

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">5e-5</span>)`,wrap:!1}}),Pt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGdldF9zY2hlZHVsZXIlMEElMEFudW1fZXBvY2hzJTIwJTNEJTIwMyUwQW51bV90cmFpbmluZ19zdGVwcyUyMCUzRCUyMG51bV9lcG9jaHMlMjAqJTIwbGVuKHRyYWluX2RhdGFsb2FkZXIpJTBBbHJfc2NoZWR1bGVyJTIwJTNEJTIwZ2V0X3NjaGVkdWxlciglMEElMjAlMjAlMjAlMjBuYW1lJTNEJTIybGluZWFyJTIyJTJDJTIwb3B0aW1pemVyJTNEb3B0aW1pemVyJTJDJTIwbnVtX3dhcm11cF9zdGVwcyUzRDAlMkMlMjBudW1fdHJhaW5pbmdfc3RlcHMlM0RudW1fdHJhaW5pbmdfc3RlcHMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> get_scheduler

<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_training_steps = num_epochs * <span class="hljs-built_in">len</span>(train_dataloader)
<span class="hljs-meta">&gt;&gt;&gt; </span>lr_scheduler = get_scheduler(
<span class="hljs-meta">... </span>    name=<span class="hljs-string">&quot;linear&quot;</span>, optimizer=optimizer, num_warmup_steps=<span class="hljs-number">0</span>, num_training_steps=num_training_steps
<span class="hljs-meta">... </span>)`,wrap:!1}}),yt=new V({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFkZXZpY2UlMjAlM0QlMjB0b3JjaC5kZXZpY2UoJTIyY3VkYSUyMiklMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwdG9yY2guZGV2aWNlKCUyMmNwdSUyMiklMEFtb2RlbC50byhkZXZpY2Up",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)`,wrap:!1}}),l=new xe({props:{$$slots:{default:[ts]},$$scope:{ctx:Wt}}}),Lt=new te({}),pe=new V({props:{code:"ZnJvbSUyMHRxZG0uYXV0byUyMGltcG9ydCUyMHRxZG0lMEElMEFwcm9ncmVzc19iYXIlMjAlM0QlMjB0cWRtKHJhbmdlKG51bV90cmFpbmluZ19zdGVwcykpJTBBJTBBbW9kZWwudHJhaW4oKSUwQWZvciUyMGVwb2NoJTIwaW4lMjByYW5nZShudW1fZXBvY2hzKSUzQSUwQSUyMCUyMCUyMCUyMGZvciUyMGJhdGNoJTIwaW4lMjB0cmFpbl9kYXRhbG9hZGVyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmF0Y2glMjAlM0QlMjAlN0JrJTNBJTIwdi50byhkZXZpY2UpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbG9zcy5iYWNrd2FyZCgpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3B0aW1pemVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxyX3NjaGVkdWxlci5zdGVwKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuemVyb19ncmFkKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcm9ncmVzc19iYXIudXBkYXRlKDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm

<span class="hljs-meta">&gt;&gt;&gt; </span>progress_bar = tqdm(<span class="hljs-built_in">range</span>(num_training_steps))

<span class="hljs-meta">&gt;&gt;&gt; </span>model.train()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_epochs):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
<span class="hljs-meta">... </span>        batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>        outputs = model(**batch)
<span class="hljs-meta">... </span>        loss = outputs.loss
<span class="hljs-meta">... </span>        loss.backward()

<span class="hljs-meta">... </span>        optimizer.step()
<span class="hljs-meta">... </span>        lr_scheduler.step()
<span class="hljs-meta">... </span>        optimizer.zero_grad()
<span class="hljs-meta">... </span>        progress_bar.update(<span class="hljs-number">1</span>)`,wrap:!1}}),ce=new te({}),fe=new V({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMmFjY3VyYWN5JTIyKSUwQW1vZGVsLmV2YWwoKSUwQWZvciUyMGJhdGNoJTIwaW4lMjBldmFsX2RhdGFsb2FkZXIlM0ElMEElMjAlMjAlMjAlMjBiYXRjaCUyMCUzRCUyMCU3QmslM0ElMjB2LnRvKGRldmljZSklMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwYmF0Y2guaXRlbXMoKSU3RCUwQSUyMCUyMCUyMCUyMHdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMEElMjAlMjAlMjAlMjBsb2dpdHMlMjAlM0QlMjBvdXRwdXRzLmxvZ2l0cyUwQSUyMCUyMCUyMCUyMHByZWRpY3Rpb25zJTIwJTNEJTIwdG9yY2guYXJnbWF4KGxvZ2l0cyUyQyUyMGRpbSUzRC0xKSUwQSUyMCUyMCUyMCUyMG1ldHJpYy5hZGRfYmF0Y2gocHJlZGljdGlvbnMlM0RwcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0RiYXRjaCU1QiUyMmxhYmVscyUyMiU1RCklMEElMEFtZXRyaWMuY29tcHV0ZSgp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;accuracy&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">eval</span>()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> eval_dataloader:
<span class="hljs-meta">... </span>    batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>    <span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>        outputs = model(**batch)

<span class="hljs-meta">... </span>    logits = outputs.logits
<span class="hljs-meta">... </span>    predictions = torch.argmax(logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    metric.add_batch(predictions=predictions, references=batch[<span class="hljs-string">&quot;labels&quot;</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>metric.compute()`,wrap:!1}}),{c(){$(m.$$.fragment),k=o(),h=r("p"),h.innerHTML=_,C=o(),Z=r("p"),Z.textContent=Ht,z=o(),$(Yt.$$.fragment),it=o(),Jt=r("p"),Jt.textContent=ee,K=o(),F=r("ol"),ht=r("li"),at=r("p"),at.innerHTML=lt,$t=o(),$(H.$$.fragment),Qt=o(),x=r("li"),mt=r("p"),mt.innerHTML=ct,W=o(),$(xt.$$.fragment),dt=o(),vt=r("li"),kt=r("p"),kt.textContent=At,Rt=o(),$(D.$$.fragment),O=o(),_t=r("p"),_t.textContent=se,tt=o(),$(ft.$$.fragment),Gt=o(),et=r("h3"),N=r("a"),R=r("span"),$(I.$$.fragment),Ct=o(),nt=r("span"),nt.textContent=bt,Xt=o(),ut=r("p"),ut.textContent=It,S=o(),$(rt.$$.fragment),jt=o(),L=r("p"),L.textContent=Et,st=o(),$(pt.$$.fragment),Mt=o(),X=r("h3"),Tt=r("a"),E=r("span"),$(Kt.$$.fragment),Ft=o(),G=r("span"),G.textContent=le,ot=o(),U=r("p"),U.innerHTML=Nt,Y=o(),$(Bt.$$.fragment),Q=o(),A=r("p"),A.innerHTML=St,B=o(),$(Pt.$$.fragment),Zt=o(),P=r("p"),P.textContent=ae,q=o(),$(yt.$$.fragment),Ut=o(),$(l.$$.fragment),d=o(),a=r("p"),a.textContent=y,gt=o(),Vt=r("h3"),wt=r("a"),Dt=r("span"),$(Lt.$$.fragment),zt=o(),re=r("span"),re.textContent=ie,qt=o(),ne=r("p"),ne.innerHTML=he,me=o(),$(pe.$$.fragment),n=o(),f=r("h3"),Ot=r("a"),oe=r("span"),$(ce.$$.fragment),we=o(),Me=r("span"),Me.textContent=ve,ye=o(),de=r("p"),de.innerHTML=be,ge=o(),$(fe.$$.fragment),this.h()},l(e){v(m.$$.fragment,e),k=i(e),h=p(e,"P",{"data-svelte-h":!0}),g(h)!=="svelte-26l7tj"&&(h.innerHTML=_),C=i(e),Z=p(e,"P",{"data-svelte-h":!0}),g(Z)!=="svelte-192c5yp"&&(Z.textContent=Ht),z=i(e),v(Yt.$$.fragment,e),it=i(e),Jt=p(e,"P",{"data-svelte-h":!0}),g(Jt)!=="svelte-108uveq"&&(Jt.textContent=ee),K=i(e),F=p(e,"OL",{});var M=w(F);ht=p(M,"LI",{});var ue=w(ht);at=p(ue,"P",{"data-svelte-h":!0}),g(at)!=="svelte-1y5q08j"&&(at.innerHTML=lt),$t=i(ue),v(H.$$.fragment,ue),ue.forEach(t),Qt=i(M),x=p(M,"LI",{});var je=w(x);mt=p(je,"P",{"data-svelte-h":!0}),g(mt)!=="svelte-1j9nsiy"&&(mt.innerHTML=ct),W=i(je),v(xt.$$.fragment,je),je.forEach(t),dt=i(M),vt=p(M,"LI",{});var Te=w(vt);kt=p(Te,"P",{"data-svelte-h":!0}),g(kt)!=="svelte-1h9qay5"&&(kt.textContent=At),Rt=i(Te),v(D.$$.fragment,Te),Te.forEach(t),M.forEach(t),O=i(e),_t=p(e,"P",{"data-svelte-h":!0}),g(_t)!=="svelte-hdideh"&&(_t.textContent=se),tt=i(e),v(ft.$$.fragment,e),Gt=i(e),et=p(e,"H3",{class:!0});var Je=w(et);N=p(Je,"A",{id:!0,class:!0,href:!0});var Ie=w(N);R=p(Ie,"SPAN",{});var We=w(R);v(I.$$.fragment,We),We.forEach(t),Ie.forEach(t),Ct=i(Je),nt=p(Je,"SPAN",{"data-svelte-h":!0}),g(nt)!=="svelte-19b0x1w"&&(nt.textContent=bt),Je.forEach(t),Xt=i(e),ut=p(e,"P",{"data-svelte-h":!0}),g(ut)!=="svelte-1ektf94"&&(ut.textContent=It),S=i(e),v(rt.$$.fragment,e),jt=i(e),L=p(e,"P",{"data-svelte-h":!0}),g(L)!=="svelte-sqozl7"&&(L.textContent=Et),st=i(e),v(pt.$$.fragment,e),Mt=i(e),X=p(e,"H3",{class:!0});var ke=w(X);Tt=p(ke,"A",{id:!0,class:!0,href:!0});var Re=w(Tt);E=p(Re,"SPAN",{});var Xe=w(E);v(Kt.$$.fragment,Xe),Xe.forEach(t),Re.forEach(t),Ft=i(ke),G=p(ke,"SPAN",{"data-svelte-h":!0}),g(G)!=="svelte-1hvdjsg"&&(G.textContent=le),ke.forEach(t),ot=i(e),U=p(e,"P",{"data-svelte-h":!0}),g(U)!=="svelte-15zsq6h"&&(U.innerHTML=Nt),Y=i(e),v(Bt.$$.fragment,e),Q=i(e),A=p(e,"P",{"data-svelte-h":!0}),g(A)!=="svelte-15mbbl4"&&(A.innerHTML=St),B=i(e),v(Pt.$$.fragment,e),Zt=i(e),P=p(e,"P",{"data-svelte-h":!0}),g(P)!=="svelte-e6t5r4"&&(P.textContent=ae),q=i(e),v(yt.$$.fragment,e),Ut=i(e),v(l.$$.fragment,e),d=i(e),a=p(e,"P",{"data-svelte-h":!0}),g(a)!=="svelte-1yeeebv"&&(a.textContent=y),gt=i(e),Vt=p(e,"H3",{class:!0});var _e=w(Vt);wt=p(_e,"A",{id:!0,class:!0,href:!0});var Ee=w(wt);Dt=p(Ee,"SPAN",{});var Be=w(Dt);v(Lt.$$.fragment,Be),Be.forEach(t),Ee.forEach(t),zt=i(_e),re=p(_e,"SPAN",{"data-svelte-h":!0}),g(re)!=="svelte-hqwlfj"&&(re.textContent=ie),_e.forEach(t),qt=i(e),ne=p(e,"P",{"data-svelte-h":!0}),g(ne)!=="svelte-1atq943"&&(ne.innerHTML=he),me=i(e),v(pe.$$.fragment,e),n=i(e),f=p(e,"H3",{class:!0});var Ce=w(f);Ot=p(Ce,"A",{id:!0,class:!0,href:!0});var Ve=w(Ot);oe=p(Ve,"SPAN",{});var ze=w(oe);v(ce.$$.fragment,ze),ze.forEach(t),Ve.forEach(t),we=i(Ce),Me=p(Ce,"SPAN",{"data-svelte-h":!0}),g(Me)!=="svelte-1nunm40"&&(Me.textContent=ve),Ce.forEach(t),ye=i(e),de=p(e,"P",{"data-svelte-h":!0}),g(de)!=="svelte-18p9q2b"&&(de.innerHTML=be),ge=i(e),v(fe.$$.fragment,e),this.h()},h(){u(N,"id","dataloader"),u(N,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(N,"href","#dataloader"),u(et,"class","relative group"),u(Tt,"id","optimizer-and-learning-rate-scheduler"),u(Tt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Tt,"href","#optimizer-and-learning-rate-scheduler"),u(X,"class","relative group"),u(wt,"id","training-loop"),u(wt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(wt,"href","#training-loop"),u(Vt,"class","relative group"),u(Ot,"id","evaluate"),u(Ot,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Ot,"href","#evaluate"),u(f,"class","relative group")},m(e,M){b(m,e,M),s(e,k,M),s(e,h,M),s(e,C,M),s(e,Z,M),s(e,z,M),b(Yt,e,M),s(e,it,M),s(e,Jt,M),s(e,K,M),s(e,F,M),c(F,ht),c(ht,at),c(ht,$t),b(H,ht,null),c(F,Qt),c(F,x),c(x,mt),c(x,W),b(xt,x,null),c(F,dt),c(F,vt),c(vt,kt),c(vt,Rt),b(D,vt,null),s(e,O,M),s(e,_t,M),s(e,tt,M),b(ft,e,M),s(e,Gt,M),s(e,et,M),c(et,N),c(N,R),b(I,R,null),c(et,Ct),c(et,nt),s(e,Xt,M),s(e,ut,M),s(e,S,M),b(rt,e,M),s(e,jt,M),s(e,L,M),s(e,st,M),b(pt,e,M),s(e,Mt,M),s(e,X,M),c(X,Tt),c(Tt,E),b(Kt,E,null),c(X,Ft),c(X,G),s(e,ot,M),s(e,U,M),s(e,Y,M),b(Bt,e,M),s(e,Q,M),s(e,A,M),s(e,B,M),b(Pt,e,M),s(e,Zt,M),s(e,P,M),s(e,q,M),b(yt,e,M),s(e,Ut,M),b(l,e,M),s(e,d,M),s(e,a,M),s(e,gt,M),s(e,Vt,M),c(Vt,wt),c(wt,Dt),b(Lt,Dt,null),c(Vt,zt),c(Vt,re),s(e,qt,M),s(e,ne,M),s(e,me,M),b(pe,e,M),s(e,n,M),s(e,f,M),c(f,Ot),c(Ot,oe),b(ce,oe,null),c(f,we),c(f,Me),s(e,ye,M),s(e,de,M),s(e,ge,M),b(fe,e,M),$e=!0},p(e,M){const ue={};M&2&&(ue.$$scope={dirty:M,ctx:e}),l.$set(ue)},i(e){$e||(j(m.$$.fragment,e),j(Yt.$$.fragment,e),j(H.$$.fragment,e),j(xt.$$.fragment,e),j(D.$$.fragment,e),j(ft.$$.fragment,e),j(I.$$.fragment,e),j(rt.$$.fragment,e),j(pt.$$.fragment,e),j(Kt.$$.fragment,e),j(Bt.$$.fragment,e),j(Pt.$$.fragment,e),j(yt.$$.fragment,e),j(l.$$.fragment,e),j(Lt.$$.fragment,e),j(pe.$$.fragment,e),j(ce.$$.fragment,e),j(fe.$$.fragment,e),$e=!0)},o(e){T(m.$$.fragment,e),T(Yt.$$.fragment,e),T(H.$$.fragment,e),T(xt.$$.fragment,e),T(D.$$.fragment,e),T(ft.$$.fragment,e),T(I.$$.fragment,e),T(rt.$$.fragment,e),T(pt.$$.fragment,e),T(Kt.$$.fragment,e),T(Bt.$$.fragment,e),T(Pt.$$.fragment,e),T(yt.$$.fragment,e),T(l.$$.fragment,e),T(Lt.$$.fragment,e),T(pe.$$.fragment,e),T(ce.$$.fragment,e),T(fe.$$.fragment,e),$e=!1},d(e){e&&(t(k),t(h),t(C),t(Z),t(z),t(it),t(Jt),t(K),t(F),t(O),t(_t),t(tt),t(Gt),t(et),t(Xt),t(ut),t(S),t(jt),t(L),t(st),t(Mt),t(X),t(ot),t(U),t(Y),t(Q),t(A),t(B),t(Zt),t(P),t(q),t(Ut),t(d),t(a),t(gt),t(Vt),t(qt),t(ne),t(me),t(n),t(f),t(ye),t(de),t(ge)),J(m,e),J(Yt,e),J(H),J(xt),J(D),J(ft,e),J(I),J(rt,e),J(pt,e),J(Kt),J(Bt,e),J(Pt,e),J(yt,e),J(l,e),J(Lt),J(pe,e),J(ce),J(fe,e)}}}function ss(Wt){let m,k;return m=new Ge({props:{$$slots:{default:[es]},$$scope:{ctx:Wt}}}),{c(){$(m.$$.fragment)},l(h){v(m.$$.fragment,h)},m(h,_){b(m,h,_),k=!0},p(h,_){const C={};_&2&&(C.$$scope={dirty:_,ctx:h}),m.$set(C)},i(h){k||(j(m.$$.fragment,h),k=!0)},o(h){T(m.$$.fragment,h),k=!1},d(h){J(m,h)}}}function as(Wt){let m,k,h,_,C,Z,Ht,z,Yt,it,Jt="사전 학습된 모델 미세 튜닝하기",ee,K,F,ht,at="사전 학습된 모델을 사용하면 상당한 이점이 있습니다. 계산 비용과 탄소발자국을 줄이고, 처음부터 모델을 학습시킬 필요 없이 최신 모델을 사용할 수 있습니다. 🤗 Transformers는 다양한 작업을 위해 사전 학습된 수천 개의 모델에 액세스할 수 있습니다. 사전 학습된 모델을 사용하는 경우, 자신의 작업과 관련된 데이터셋을 사용해 학습합니다. 이것은 미세 튜닝이라고 하는 매우 강력한 훈련 기법입니다. 이 튜토리얼에서는 당신이 선택한 딥러닝 프레임워크로 사전 학습된 모델을 미세 튜닝합니다:",lt,$t,H="<li>🤗 Transformers로 사전 학습된 모델 미세 튜닝하기 <code>Trainer</code>.</li> <li>Keras를 사용하여 TensorFlow에서 사전 학습된 모델을 미세 튜닝하기.</li> <li>기본 PyTorch에서 사전 학습된 모델을 미세 튜닝하기.</li>",Qt,x,mt,ct,W,xt,dt,vt,kt,At="데이터셋 준비",Rt,D,O,_t,se="사전 학습된 모델을 미세 튜닝하기 위해서 데이터셋을 다운로드하고 훈련할 수 있도록 준비하세요. 이전 튜토리얼에서 훈련을 위해 데이터를 처리하는 방법을 보여드렸는데, 지금이 배울 걸 되짚을 기회입니다!",tt,ft,Gt='먼저 <a href="https://huggingface.co/datasets/yelp_review_full" rel="nofollow">Yelp 리뷰</a> 데이터 세트를 로드합니다:',et,N,R,I,Ct='텍스트를 처리하고 서로 다른 길이의 시퀀스 패딩 및 잘라내기 전략을 포함하려면 토크나이저가 필요합니다. 데이터셋을 한 번에 처리하려면 🤗 Dataset <a href="https://huggingface.co/docs/datasets/process.html#map" rel="nofollow"><code>map</code></a> 메서드를 사용하여 전체 데이터셋에 전처리 함수를 적용하세요:',nt,bt,Xt,ut,It="필요한 경우 미세 튜닝을 위해 데이터셋의 작은 부분 집합을 만들어 미세 튜닝 작업 시간을 줄일 수 있습니다:",S,rt,jt,L,Et,st,pt,Mt,X,Tt,E,Kt="Train",Ft,G,le="여기서부터는 사용하려는 프레임워크에 해당하는 섹션을 따라야 합니다. 오른쪽 사이드바의 링크를 사용하여 원하는 프레임워크로 이동할 수 있으며, 특정 프레임워크의 모든 콘텐츠를 숨기려면 해당 프레임워크 블록의 오른쪽 상단에 있는 버튼을 사용하면 됩니다!",ot,U,Nt,Y,Bt,Q,A,St,B,Pt,Zt,P="기본 파이토치로 훈련하기",ae,q,yt,Ut,l,d,a,y,gt,Vt,wt,Dt="추가 자료",Lt,zt,re="더 많은 미세 튜닝 예제는 다음을 참조하세요:",ie,qt,ne='<li><p><a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">🤗 Trnasformers 예제</a>에는 PyTorch 및 텐서플로우에서 일반적인 NLP 작업을 훈련할 수 있는 스크립트가 포함되어 있습니다.</p></li> <li><p><a href="notebooks">🤗 Transformers 노트북</a>에는 PyTorch 및 텐서플로우에서 특정 작업을 위해 모델을 미세 튜닝하는 방법에 대한 다양한 노트북이 포함되어 있습니다.</p></li>',he,me,pe;return z=new te({}),K=new Le({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ko/training.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ko/pytorch/training.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/ko/tensorflow/training.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/training.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/pytorch/training.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/ko/tensorflow/training.ipynb"}]}}),dt=new te({}),D=new Ze({props:{id:"_BZearw7f0w"}}),N=new V({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJ5ZWxwX3Jldmlld19mdWxsJTIyKSUwQWRhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCU1QjEwMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;yelp_review_full&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">100</span>]
{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My expectations for McDonalds are t rarely high. But for one to still fail so spectacularly...that takes something special!\\\\nThe cashier took my friends\\&#x27;s order, then promptly ignored me. I had to force myself in front of a cashier who opened his register to wait on the person BEHIND me. I waited over five minutes for a gigantic order that included precisely one kid\\&#x27;s meal. After watching two people who ordered after me be handed their food, I asked where mine was. The manager started yelling at the cashiers for \\\\&quot;serving off their orders\\\\&quot; when they didn\\&#x27;t have their food. But neither cashier was anywhere near those controls, and the manager was the one serving food to customers and clearing the boards.\\\\nThe manager was rude when giving me my order. She didn\\&#x27;t make sure that I had everything ON MY RECEIPT, and never even had the decency to apologize that I felt I was getting poor service.\\\\nI\\&#x27;ve eaten at various McDonalds restaurants for over 30 years. I\\&#x27;ve worked at more than one location. I expect bad days, bad moods, and the occasional mistake. But I have yet to have a decent experience at this store. It will remain a place I avoid unless someone in my party needs to avoid illness from low blood sugar. Perhaps I should go back to the racially biased service of Steak n Shake instead!&#x27;</span>}`,wrap:!1}}),bt=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTBBJTBBZGVmJTIwdG9rZW5pemVfZnVuY3Rpb24oZXhhbXBsZXMpJTNBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdG9rZW5pemVyKGV4YW1wbGVzJTVCJTIydGV4dCUyMiU1RCUyQyUyMHBhZGRpbmclM0QlMjJtYXhfbGVuZ3RoJTIyJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUpJTBBJTBBJTBBdG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwZGF0YXNldC5tYXAodG9rZW5pemVfZnVuY3Rpb24lMkMlMjBiYXRjaGVkJTNEVHJ1ZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(examples[<span class="hljs-string">&quot;text&quot;</span>], padding=<span class="hljs-string">&quot;max_length&quot;</span>, truncation=<span class="hljs-literal">True</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = dataset.<span class="hljs-built_in">map</span>(tokenize_function, batched=<span class="hljs-literal">True</span>)`,wrap:!1}}),rt=new V({props:{code:"c21hbGxfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnNodWZmbGUoc2VlZCUzRDQyKS5zZWxlY3QocmFuZ2UoMTAwMCkpJTBBc21hbGxfZXZhbF9kYXRhc2V0JTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzJTVCJTIydGVzdCUyMiU1RC5zaHVmZmxlKHNlZWQlM0Q0Mikuc2VsZWN0KHJhbmdlKDEwMDApKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>small_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>small_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;test&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))`,wrap:!1}}),X=new te({}),U=new He({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Oe],pytorch:[qe]},$$scope:{ctx:Wt}}}),B=new te({}),q=new He({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[ss]},$$scope:{ctx:Wt}}}),gt=new te({}),{c(){m=r("meta"),k=o(),h=r("p"),_=o(),C=r("h1"),Z=r("a"),Ht=r("span"),$(z.$$.fragment),Yt=o(),it=r("span"),it.textContent=Jt,ee=o(),$(K.$$.fragment),F=o(),ht=r("p"),ht.textContent=at,lt=o(),$t=r("ul"),$t.innerHTML=H,Qt=o(),x=r("a"),mt=o(),ct=r("h2"),W=r("a"),xt=r("span"),$(dt.$$.fragment),vt=o(),kt=r("span"),kt.textContent=At,Rt=o(),$(D.$$.fragment),O=o(),_t=r("p"),_t.textContent=se,tt=o(),ft=r("p"),ft.innerHTML=Gt,et=o(),$(N.$$.fragment),R=o(),I=r("p"),I.innerHTML=Ct,nt=o(),$(bt.$$.fragment),Xt=o(),ut=r("p"),ut.textContent=It,S=o(),$(rt.$$.fragment),jt=o(),L=r("a"),Et=o(),st=r("h2"),pt=r("a"),Mt=r("span"),$(X.$$.fragment),Tt=o(),E=r("span"),E.textContent=Kt,Ft=o(),G=r("p"),G.textContent=le,ot=o(),$(U.$$.fragment),Nt=o(),Y=r("a"),Bt=o(),Q=r("h2"),A=r("a"),St=r("span"),$(B.$$.fragment),Pt=o(),Zt=r("span"),Zt.textContent=P,ae=o(),$(q.$$.fragment),yt=o(),Ut=r("a"),l=o(),d=r("h2"),a=r("a"),y=r("span"),$(gt.$$.fragment),Vt=o(),wt=r("span"),wt.textContent=Dt,Lt=o(),zt=r("p"),zt.textContent=re,ie=o(),qt=r("ul"),qt.innerHTML=ne,he=o(),me=r("p"),this.h()},l(n){const f=Se("svelte-1phssyn",document.head);m=p(f,"META",{name:!0,content:!0}),f.forEach(t),k=i(n),h=p(n,"P",{}),w(h).forEach(t),_=i(n),C=p(n,"H1",{class:!0});var Ot=w(C);Z=p(Ot,"A",{id:!0,class:!0,href:!0});var oe=w(Z);Ht=p(oe,"SPAN",{});var ce=w(Ht);v(z.$$.fragment,ce),ce.forEach(t),oe.forEach(t),Yt=i(Ot),it=p(Ot,"SPAN",{"data-svelte-h":!0}),g(it)!=="svelte-17fdw86"&&(it.textContent=Jt),Ot.forEach(t),ee=i(n),v(K.$$.fragment,n),F=i(n),ht=p(n,"P",{"data-svelte-h":!0}),g(ht)!=="svelte-lewprv"&&(ht.textContent=at),lt=i(n),$t=p(n,"UL",{"data-svelte-h":!0}),g($t)!=="svelte-6blpq0"&&($t.innerHTML=H),Qt=i(n),x=p(n,"A",{id:!0}),w(x).forEach(t),mt=i(n),ct=p(n,"H2",{class:!0});var we=w(ct);W=p(we,"A",{id:!0,class:!0,href:!0});var Me=w(W);xt=p(Me,"SPAN",{});var ve=w(xt);v(dt.$$.fragment,ve),ve.forEach(t),Me.forEach(t),vt=i(we),kt=p(we,"SPAN",{"data-svelte-h":!0}),g(kt)!=="svelte-1ixk6yw"&&(kt.textContent=At),we.forEach(t),Rt=i(n),v(D.$$.fragment,n),O=i(n),_t=p(n,"P",{"data-svelte-h":!0}),g(_t)!=="svelte-agqeit"&&(_t.textContent=se),tt=i(n),ft=p(n,"P",{"data-svelte-h":!0}),g(ft)!=="svelte-1w9wcpp"&&(ft.innerHTML=Gt),et=i(n),v(N.$$.fragment,n),R=i(n),I=p(n,"P",{"data-svelte-h":!0}),g(I)!=="svelte-kuz32y"&&(I.innerHTML=Ct),nt=i(n),v(bt.$$.fragment,n),Xt=i(n),ut=p(n,"P",{"data-svelte-h":!0}),g(ut)!=="svelte-jaac36"&&(ut.textContent=It),S=i(n),v(rt.$$.fragment,n),jt=i(n),L=p(n,"A",{id:!0}),w(L).forEach(t),Et=i(n),st=p(n,"H2",{class:!0});var ye=w(st);pt=p(ye,"A",{id:!0,class:!0,href:!0});var de=w(pt);Mt=p(de,"SPAN",{});var be=w(Mt);v(X.$$.fragment,be),be.forEach(t),de.forEach(t),Tt=i(ye),E=p(ye,"SPAN",{"data-svelte-h":!0}),g(E)!=="svelte-5arm0l"&&(E.textContent=Kt),ye.forEach(t),Ft=i(n),G=p(n,"P",{"data-svelte-h":!0}),g(G)!=="svelte-12mtsa7"&&(G.textContent=le),ot=i(n),v(U.$$.fragment,n),Nt=i(n),Y=p(n,"A",{id:!0}),w(Y).forEach(t),Bt=i(n),Q=p(n,"H2",{class:!0});var ge=w(Q);A=p(ge,"A",{id:!0,class:!0,href:!0});var fe=w(A);St=p(fe,"SPAN",{});var $e=w(St);v(B.$$.fragment,$e),$e.forEach(t),fe.forEach(t),Pt=i(ge),Zt=p(ge,"SPAN",{"data-svelte-h":!0}),g(Zt)!=="svelte-1555oen"&&(Zt.textContent=P),ge.forEach(t),ae=i(n),v(q.$$.fragment,n),yt=i(n),Ut=p(n,"A",{id:!0}),w(Ut).forEach(t),l=i(n),d=p(n,"H2",{class:!0});var e=w(d);a=p(e,"A",{id:!0,class:!0,href:!0});var M=w(a);y=p(M,"SPAN",{});var ue=w(y);v(gt.$$.fragment,ue),ue.forEach(t),M.forEach(t),Vt=i(e),wt=p(e,"SPAN",{"data-svelte-h":!0}),g(wt)!=="svelte-1x7i9sz"&&(wt.textContent=Dt),e.forEach(t),Lt=i(n),zt=p(n,"P",{"data-svelte-h":!0}),g(zt)!=="svelte-1nv5qh9"&&(zt.textContent=re),ie=i(n),qt=p(n,"UL",{"data-svelte-h":!0}),g(qt)!=="svelte-7q2z1g"&&(qt.innerHTML=ne),he=i(n),me=p(n,"P",{}),w(me).forEach(t),this.h()},h(){u(m,"name","hf:doc:metadata"),u(m,"content",JSON.stringify(ls)),u(Z,"id","finetune-a-pretrained-model"),u(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Z,"href","#finetune-a-pretrained-model"),u(C,"class","relative group"),u(x,"id","data-processing"),u(W,"id","prepare-a-dataset"),u(W,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(W,"href","#prepare-a-dataset"),u(ct,"class","relative group"),u(L,"id","trainer"),u(pt,"id","train"),u(pt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(pt,"href","#train"),u(st,"class","relative group"),u(Y,"id","pytorch_native"),u(A,"id","train-in-native-pytorch"),u(A,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(A,"href","#train-in-native-pytorch"),u(Q,"class","relative group"),u(Ut,"id","additional-resources"),u(a,"id","additional-resources"),u(a,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(a,"href","#additional-resources"),u(d,"class","relative group")},m(n,f){c(document.head,m),s(n,k,f),s(n,h,f),s(n,_,f),s(n,C,f),c(C,Z),c(Z,Ht),b(z,Ht,null),c(C,Yt),c(C,it),s(n,ee,f),b(K,n,f),s(n,F,f),s(n,ht,f),s(n,lt,f),s(n,$t,f),s(n,Qt,f),s(n,x,f),s(n,mt,f),s(n,ct,f),c(ct,W),c(W,xt),b(dt,xt,null),c(ct,vt),c(ct,kt),s(n,Rt,f),b(D,n,f),s(n,O,f),s(n,_t,f),s(n,tt,f),s(n,ft,f),s(n,et,f),b(N,n,f),s(n,R,f),s(n,I,f),s(n,nt,f),b(bt,n,f),s(n,Xt,f),s(n,ut,f),s(n,S,f),b(rt,n,f),s(n,jt,f),s(n,L,f),s(n,Et,f),s(n,st,f),c(st,pt),c(pt,Mt),b(X,Mt,null),c(st,Tt),c(st,E),s(n,Ft,f),s(n,G,f),s(n,ot,f),b(U,n,f),s(n,Nt,f),s(n,Y,f),s(n,Bt,f),s(n,Q,f),c(Q,A),c(A,St),b(B,St,null),c(Q,Pt),c(Q,Zt),s(n,ae,f),b(q,n,f),s(n,yt,f),s(n,Ut,f),s(n,l,f),s(n,d,f),c(d,a),c(a,y),b(gt,y,null),c(d,Vt),c(d,wt),s(n,Lt,f),s(n,zt,f),s(n,ie,f),s(n,qt,f),s(n,he,f),s(n,me,f),pe=!0},p(n,[f]){const Ot={};f&2&&(Ot.$$scope={dirty:f,ctx:n}),U.$set(Ot);const oe={};f&2&&(oe.$$scope={dirty:f,ctx:n}),q.$set(oe)},i(n){pe||(j(z.$$.fragment,n),j(K.$$.fragment,n),j(dt.$$.fragment,n),j(D.$$.fragment,n),j(N.$$.fragment,n),j(bt.$$.fragment,n),j(rt.$$.fragment,n),j(X.$$.fragment,n),j(U.$$.fragment,n),j(B.$$.fragment,n),j(q.$$.fragment,n),j(gt.$$.fragment,n),pe=!0)},o(n){T(z.$$.fragment,n),T(K.$$.fragment,n),T(dt.$$.fragment,n),T(D.$$.fragment,n),T(N.$$.fragment,n),T(bt.$$.fragment,n),T(rt.$$.fragment,n),T(X.$$.fragment,n),T(U.$$.fragment,n),T(B.$$.fragment,n),T(q.$$.fragment,n),T(gt.$$.fragment,n),pe=!1},d(n){n&&(t(k),t(h),t(_),t(C),t(ee),t(F),t(ht),t(lt),t($t),t(Qt),t(x),t(mt),t(ct),t(Rt),t(O),t(_t),t(tt),t(ft),t(et),t(R),t(I),t(nt),t(Xt),t(ut),t(S),t(jt),t(L),t(Et),t(st),t(Ft),t(G),t(ot),t(Nt),t(Y),t(Bt),t(Q),t(ae),t(yt),t(Ut),t(l),t(d),t(Lt),t(zt),t(ie),t(qt),t(he),t(me)),t(m),J(z),J(K,n),J(dt),J(D,n),J(N,n),J(bt,n),J(rt,n),J(X),J(U,n),J(B),J(q,n),J(gt)}}}const ls={local:"finetune-a-pretrained-model",sections:[{local:"prepare-a-dataset",title:"데이터셋 준비"},{local:"train",title:"Train"},{local:"train-with-pytorch-trainer",sections:[{local:"training-hyperparameters",title:"하이퍼파라미터 훈련"},{local:"evaluate",title:"평가 하기"},{local:"trainer",title:"훈련 하기"}],title:"파이토치 Trainer로 훈련하기"},{local:"train-a-tensorflow-model-with-keras",sections:[{local:"loading-data-for-keras",title:"Keras용 데이터 로드"},{local:"loading-data-as-a-tfdatadataset",title:"데이터를 tf.data.Dataset으로 로드하기"}],title:"Keras로 텐서플로우 모델 훈련하기"},{local:"train-in-native-pytorch",sections:[{local:"dataloader",title:"DataLoader"},{local:"optimizer-and-learning-rate-scheduler",title:"옵티마이저 및 학습 속도 스케줄러"},{local:"training-loop",title:"훈련 루프"},{local:"evaluate",title:"평가 하기"}],title:"기본 파이토치로 훈련하기"},{local:"additional-resources",title:"추가 자료"}],title:"사전 학습된 모델 미세 튜닝하기"};function ns(Wt){return Ae(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fs extends Fe{constructor(m){super(),Ne(this,m,ns,as,Ye,{})}}export{fs as component};
