import{s as ne,o as se,n as P}from"../chunks/scheduler.6062bdaf.js";import{S as ie,i as le,g,s as u,r as y,A as ce,h as f,f as a,c as p,j as q,u as b,x as C,k as N,y as S,a as l,v as _,d as $,t as w,w as M}from"../chunks/index.4bca734e.js";import{T as me}from"../chunks/Tip.b9ac1f03.js";import{D as ue}from"../chunks/Docstring.d7918b6d.js";import{C as ae}from"../chunks/CodeBlock.fa01571c.js";import{E as re}from"../chunks/ExampleCodeBlock.d27cbfa4.js";import{H as oe,E as pe}from"../chunks/EditOnGithub.74ab2baa.js";function de(T){let t,c="<code>HFSummaryWriter</code> is experimental. Its API is subject to change in the future without prior notice.";return{c(){t=g("p"),t.innerHTML=c},l(r){t=f(r,"P",{"data-svelte-h":!0}),C(t)!=="svelte-1jyxcko"&&(t.innerHTML=c)},m(r,i){l(r,t,i)},p:P,d(r){r&&a(t)}}}function he(T){let t,c="Examples:",r,i,d;return i=new ae({props:{code:"JTIzJTIwVGFrZW4lMjBmcm9tJTIwaHR0cHMlM0ElMkYlMkZweXRvcmNoLm9yZyUyRmRvY3MlMkZzdGFibGUlMkZ0ZW5zb3Jib2FyZC5odG1sJTBBLSUyMGZyb20lMjB0b3JjaC51dGlscy50ZW5zb3Jib2FyZCUyMGltcG9ydCUyMFN1bW1hcnlXcml0ZXIlMEElMkIlMjBmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwSEZTdW1tYXJ5V3JpdGVyJTBBJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBLSUyMHdyaXRlciUyMCUzRCUyMFN1bW1hcnlXcml0ZXIoKSUwQSUyQiUyMHdyaXRlciUyMCUzRCUyMEhGU3VtbWFyeVdyaXRlcihyZXBvX2lkJTNEJTIydXNlcm5hbWUlMkZteS10cmFpbmVkLW1vZGVsJTIyKSUwQSUwQWZvciUyMG5faXRlciUyMGluJTIwcmFuZ2UoMTAwKSUzQSUwQSUyMCUyMCUyMCUyMHdyaXRlci5hZGRfc2NhbGFyKCdMb3NzJTJGdHJhaW4nJTJDJTIwbnAucmFuZG9tLnJhbmRvbSgpJTJDJTIwbl9pdGVyKSUwQSUyMCUyMCUyMCUyMHdyaXRlci5hZGRfc2NhbGFyKCdMb3NzJTJGdGVzdCclMkMlMjBucC5yYW5kb20ucmFuZG9tKCklMkMlMjBuX2l0ZXIpJTBBJTIwJTIwJTIwJTIwd3JpdGVyLmFkZF9zY2FsYXIoJ0FjY3VyYWN5JTJGdHJhaW4nJTJDJTIwbnAucmFuZG9tLnJhbmRvbSgpJTJDJTIwbl9pdGVyKSUwQSUyMCUyMCUyMCUyMHdyaXRlci5hZGRfc2NhbGFyKCdBY2N1cmFjeSUyRnRlc3QnJTJDJTIwbnAucmFuZG9tLnJhbmRvbSgpJTJDJTIwbl9pdGVyKQ==",highlighted:`# Taken from https://pytorch.org/docs/stable/tensorboard.html
<span class="hljs-deletion">- from torch.utils.tensorboard import SummaryWriter</span>
<span class="hljs-addition">+ from huggingface_hub import HFSummaryWriter</span>

import numpy as np

<span class="hljs-deletion">- writer = SummaryWriter()</span>
<span class="hljs-addition">+ writer = HFSummaryWriter(repo_id=&quot;username/my-trained-model&quot;)</span>

for n_iter in range(100):
    writer.add_scalar(&#x27;Loss/train&#x27;, np.random.random(), n_iter)
    writer.add_scalar(&#x27;Loss/test&#x27;, np.random.random(), n_iter)
    writer.add_scalar(&#x27;Accuracy/train&#x27;, np.random.random(), n_iter)
    writer.add_scalar(&#x27;Accuracy/test&#x27;, np.random.random(), n_iter)`,wrap:!1}}),{c(){t=g("p"),t.textContent=c,r=u(),y(i.$$.fragment)},l(n){t=f(n,"P",{"data-svelte-h":!0}),C(t)!=="svelte-kvfsh7"&&(t.textContent=c),r=p(n),b(i.$$.fragment,n)},m(n,h){l(n,t,h),l(n,r,h),_(i,n,h),d=!0},p:P,i(n){d||($(i.$$.fragment,n),d=!0)},o(n){w(i.$$.fragment,n),d=!1},d(n){n&&(a(t),a(r)),M(i,n)}}}function ge(T){let t,c;return t=new ae({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhGU3VtbWFyeVdyaXRlciUwQSUwQXdpdGglMjBIRlN1bW1hcnlXcml0ZXIocmVwb19pZCUzRCUyMnRlc3RfaGZfbG9nZ2VyJTIyJTJDJTIwY29tbWl0X2V2ZXJ5JTNEMTUpJTIwYXMlMjBsb2dnZXIlM0ElMEElMjAlMjAlMjAlMjBsb2dnZXIuYWRkX3NjYWxhciglMjJhJTIyJTJDJTIwMSklMEElMjAlMjAlMjAlMjBsb2dnZXIuYWRkX3NjYWxhciglMjJiJTIyJTJDJTIwMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HFSummaryWriter

<span class="hljs-comment"># Logs are automatically pushed every 15 minutes (5 by default) + when exiting the context manager</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> HFSummaryWriter(repo_id=<span class="hljs-string">&quot;test_hf_logger&quot;</span>, commit_every=<span class="hljs-number">15</span>) <span class="hljs-keyword">as</span> logger:
<span class="hljs-meta">... </span>    logger.add_scalar(<span class="hljs-string">&quot;a&quot;</span>, <span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    logger.add_scalar(<span class="hljs-string">&quot;b&quot;</span>, <span class="hljs-number">2</span>)`,wrap:!1}}),{c(){y(t.$$.fragment)},l(r){b(t.$$.fragment,r)},m(r,i){_(t,r,i),c=!0},p:P,i(r){c||($(t.$$.fragment,r),c=!0)},o(r){w(t.$$.fragment,r),c=!1},d(r){M(t,r)}}}function fe(T){let t,c,r,i,d,n,h,z=`TensorBoard는 기계학습 실험을 위한 시각화 도구입니다. 주로 손실 및 정확도와 같은 지표를 추적 및 시각화하고, 모델 그래프와
히스토그램을 보여주고, 이미지를 표시하는 등 다양한 기능을 제공합니다. 또한 TensorBoard는 Hugging Face Hub와 잘 통합되어 있습니다.
<code>tfevents</code> 같은 TensorBoard 추적을 Hub에 푸시하면 Hub는 이를 자동으로 감지하여 시각화 인스턴스를 시작합니다.
TensorBoard와 Hub의 통합에 대한 자세한 정보는 <a href="https://huggingface.co/docs/hub/tensorboard" rel="nofollow">가이드</a>를 확인하세요.`,G,x,Q=`이 통합을 위해, <code>huggingface_hub</code>는 로그를 Hub로 푸시하기 위한 사용자 정의 로거를 제공합니다.
이 로거는 추가적인 코드 없이 <a href="https://tensorboardx.readthedocs.io/en/latest/tensorboard.html" rel="nofollow">SummaryWriter</a>의 대체제로 사용될 수 있습니다.
추적은 계속해서 로컬에 저장되며 백그라운드 작업이 일정한 시간마다 Hub에 푸시하는 형태로 동작합니다.`,Z,v,B,s,F,D,k,K="Wrapper around the tensorboard’s <code>SummaryWriter</code> to push training logs to the Hub.",E,j,O=`Data is logged locally and then pushed to the Hub asynchronously. Pushing data to the Hub is done in a separate
thread to avoid blocking the training script. In particular, if the upload fails for any reason (e.g. a connection
issue), the main script will not be interrupted. Data is automatically pushed to the Hub every <code>commit_every</code>
minutes (default to every 5 minutes).`,V,J,A,H,Y,W,X,U,R,I,L;return d=new oe({props:{title:"TensorBoard 로거",local:"tensorboard-logger",headingTag:"h1"}}),v=new oe({props:{title:"HFSummaryWriter",local:"huggingface_hub.HFSummaryWriter ][ huggingface_hub.HFSummaryWriter",headingTag:"h2"}}),F=new ue({props:{name:"class huggingface_hub.HFSummaryWriter",anchor:"huggingface_hub.HFSummaryWriter",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"huggingface_hub.HFSummaryWriter.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) &#x2014;
The id of the repo to which the logs will be pushed.`,name:"repo_id"},{anchor:"huggingface_hub.HFSummaryWriter.logdir",description:`<strong>logdir</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The directory where the logs will be written. If not specified, a local directory will be created by the
underlying <code>SummaryWriter</code> object.`,name:"logdir"},{anchor:"huggingface_hub.HFSummaryWriter.commit_every",description:`<strong>commit_every</strong> (<code>int</code> or <code>float</code>, <em>optional</em>) &#x2014;
The frequency (in minutes) at which the logs will be pushed to the Hub. Defaults to 5 minutes.`,name:"commit_every"},{anchor:"huggingface_hub.HFSummaryWriter.squash_history",description:`<strong>squash_history</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to squash the history of the repo after each commit. Defaults to <code>False</code>. Squashing commits is
useful to avoid degraded performances on the repo when it grows too large.`,name:"squash_history"},{anchor:"huggingface_hub.HFSummaryWriter.repo_type",description:`<strong>repo_type</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The type of the repo to which the logs will be pushed. Defaults to &#x201C;model&#x201D;.`,name:"repo_type"},{anchor:"huggingface_hub.HFSummaryWriter.repo_revision",description:`<strong>repo_revision</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The revision of the repo to which the logs will be pushed. Defaults to &#x201C;main&#x201D;.`,name:"repo_revision"},{anchor:"huggingface_hub.HFSummaryWriter.repo_private",description:`<strong>repo_private</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to create a private repo or not. Defaults to False. This argument is ignored if the repo already
exists.`,name:"repo_private"},{anchor:"huggingface_hub.HFSummaryWriter.path_in_repo",description:`<strong>path_in_repo</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The path to the folder in the repo where the logs will be pushed. Defaults to &#x201C;tensorboard/&#x201C;.`,name:"path_in_repo"},{anchor:"huggingface_hub.HFSummaryWriter.repo_allow_patterns",description:`<strong>repo_allow_patterns</strong> (<code>List[str]</code> or <code>str</code>, <em>optional</em>) &#x2014;
A list of patterns to include in the upload. Defaults to <code>&quot;*.tfevents.*&quot;</code>. Check out the
<a href="https://huggingface.co/docs/huggingface_hub/guides/upload#upload-a-folder" rel="nofollow">upload guide</a> for more details.`,name:"repo_allow_patterns"},{anchor:"huggingface_hub.HFSummaryWriter.repo_ignore_patterns",description:`<strong>repo_ignore_patterns</strong> (<code>List[str]</code> or <code>str</code>, <em>optional</em>) &#x2014;
A list of patterns to exclude in the upload. Check out the
<a href="https://huggingface.co/docs/huggingface_hub/guides/upload#upload-a-folder" rel="nofollow">upload guide</a> for more details.`,name:"repo_ignore_patterns"},{anchor:"huggingface_hub.HFSummaryWriter.token",description:`<strong>token</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Authentication token. Will default to the stored token. See <a href="https://huggingface.co/settings/token" rel="nofollow">https://huggingface.co/settings/token</a> for more
details
kwargs &#x2014;
Additional keyword arguments passed to <code>SummaryWriter</code>.`,name:"token"}],source:"https://github.com/huggingface/huggingface_hub/blob/vr_2254/src/huggingface_hub/_tensorboard_logger.py#L46"}}),J=new me({props:{warning:!0,$$slots:{default:[de]},$$scope:{ctx:T}}}),H=new re({props:{anchor:"huggingface_hub.HFSummaryWriter.example",$$slots:{default:[he]},$$scope:{ctx:T}}}),W=new re({props:{anchor:"huggingface_hub.HFSummaryWriter.example-2",$$slots:{default:[ge]},$$scope:{ctx:T}}}),U=new pe({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/ko/package_reference/tensorboard.md"}}),{c(){t=g("meta"),c=u(),r=g("p"),i=u(),y(d.$$.fragment),n=u(),h=g("p"),h.innerHTML=z,G=u(),x=g("p"),x.innerHTML=Q,Z=u(),y(v.$$.fragment),B=u(),s=g("div"),y(F.$$.fragment),D=u(),k=g("p"),k.innerHTML=K,E=u(),j=g("p"),j.innerHTML=O,V=u(),y(J.$$.fragment),A=u(),y(H.$$.fragment),Y=u(),y(W.$$.fragment),X=u(),y(U.$$.fragment),R=u(),I=g("p"),this.h()},l(e){const o=ce("svelte-u9bgzb",document.head);t=f(o,"META",{name:!0,content:!0}),o.forEach(a),c=p(e),r=f(e,"P",{}),q(r).forEach(a),i=p(e),b(d.$$.fragment,e),n=p(e),h=f(e,"P",{"data-svelte-h":!0}),C(h)!=="svelte-a0nj69"&&(h.innerHTML=z),G=p(e),x=f(e,"P",{"data-svelte-h":!0}),C(x)!=="svelte-8u26do"&&(x.innerHTML=Q),Z=p(e),b(v.$$.fragment,e),B=p(e),s=f(e,"DIV",{class:!0});var m=q(s);b(F.$$.fragment,m),D=p(m),k=f(m,"P",{"data-svelte-h":!0}),C(k)!=="svelte-1gj9gtd"&&(k.innerHTML=K),E=p(m),j=f(m,"P",{"data-svelte-h":!0}),C(j)!=="svelte-37hlnu"&&(j.innerHTML=O),V=p(m),b(J.$$.fragment,m),A=p(m),b(H.$$.fragment,m),Y=p(m),b(W.$$.fragment,m),m.forEach(a),X=p(e),b(U.$$.fragment,e),R=p(e),I=f(e,"P",{}),q(I).forEach(a),this.h()},h(){N(t,"name","hf:doc:metadata"),N(t,"content",ye),N(s,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,o){S(document.head,t),l(e,c,o),l(e,r,o),l(e,i,o),_(d,e,o),l(e,n,o),l(e,h,o),l(e,G,o),l(e,x,o),l(e,Z,o),_(v,e,o),l(e,B,o),l(e,s,o),_(F,s,null),S(s,D),S(s,k),S(s,E),S(s,j),S(s,V),_(J,s,null),S(s,A),_(H,s,null),S(s,Y),_(W,s,null),l(e,X,o),_(U,e,o),l(e,R,o),l(e,I,o),L=!0},p(e,[o]){const m={};o&2&&(m.$$scope={dirty:o,ctx:e}),J.$set(m);const ee={};o&2&&(ee.$$scope={dirty:o,ctx:e}),H.$set(ee);const te={};o&2&&(te.$$scope={dirty:o,ctx:e}),W.$set(te)},i(e){L||($(d.$$.fragment,e),$(v.$$.fragment,e),$(F.$$.fragment,e),$(J.$$.fragment,e),$(H.$$.fragment,e),$(W.$$.fragment,e),$(U.$$.fragment,e),L=!0)},o(e){w(d.$$.fragment,e),w(v.$$.fragment,e),w(F.$$.fragment,e),w(J.$$.fragment,e),w(H.$$.fragment,e),w(W.$$.fragment,e),w(U.$$.fragment,e),L=!1},d(e){e&&(a(c),a(r),a(i),a(n),a(h),a(G),a(x),a(Z),a(B),a(s),a(X),a(R),a(I)),a(t),M(d,e),M(v,e),M(F),M(J),M(H),M(W),M(U,e)}}}const ye='{"title":"TensorBoard 로거","local":"tensorboard-logger","sections":[{"title":"HFSummaryWriter","local":"huggingface_hub.HFSummaryWriter ][ huggingface_hub.HFSummaryWriter","sections":[],"depth":2}],"depth":1}';function be(T){return se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class We extends ie{constructor(t){super(),le(this,t,be,fe,ne,{})}}export{We as component};
