import{S as ka,i as va,s as Ea,e as n,k as m,w,t as l,M as wa,c as p,d as s,m as c,x as j,a as i,h as o,b as T,G as t,g as r,y,q as C,o as q,B as g,v as ja}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ms}from"../../chunks/Tip-hf-doc-builder.js";import{Y as Os}from"../../chunks/Youtube-hf-doc-builder.js";import{I as ya}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as M}from"../../chunks/CodeBlock-hf-doc-builder.js";import{C as Ca}from"../../chunks/CourseFloatingBanner-hf-doc-builder.js";import{F as qa}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";import"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function ga(K){let f,b,u,k,$;return{c(){f=n("p"),b=l("\u8BF7\u6CE8\u610F\u{1F917} Transformers \u6A21\u578B\u5177\u6709\u5927\u591A\u6570 Keras \u6A21\u578B\u6240\u6CA1\u6709\u7684\u7279\u6B8A\u80FD\u529B\u2014\u2014\u5B83\u4EEC\u53EF\u4EE5\u81EA\u52A8\u4F7F\u7528\u5185\u90E8\u8BA1\u7B97\u7684loss\u3002 \u5982\u679C\u60A8\u6CA1\u6709\u5728 "),u=n("code"),k=l("compile()"),$=l(" \u4E2D\u8BBE\u7F6E\u635F\u5931\u51FD\u6570\uFF0C\u4ED6\u4EEC\u5C06\u9ED8\u8BA4\u4F7F\u7528\u5185\u90E8\u8BA1\u7B97\u7684\u635F\u5931\u3002 \u8BF7\u6CE8\u610F\uFF0C\u8981\u4F7F\u7528\u5185\u90E8\u635F\u5931\uFF0C\u60A8\u9700\u8981\u5C06\u6807\u7B7E\u4F5C\u4E3A\u8F93\u5165\u7684\u4E00\u90E8\u5206\u4F20\u9012\uFF0C\u800C\u4E0D\u662F\u4F5C\u4E3A\u5355\u72EC\u7684\u6807\u7B7E\uFF08\u8FD9\u662F\u5728 Keras \u6A21\u578B\u4E2D\u4F7F\u7528\u6807\u7B7E\u7684\u6B63\u5E38\u65B9\u5F0F\uFF09\u3002 \u60A8\u5C06\u5728\u8BFE\u7A0B\u7684\u7B2C 2 \u90E8\u5206\u4E2D\u770B\u5230\u8FD9\u65B9\u9762\u7684\u793A\u4F8B\uFF0C\u5176\u4E2D\u5B9A\u4E49\u6B63\u786E\u7684\u635F\u5931\u51FD\u6570\u53EF\u80FD\u5F88\u68D8\u624B\u3002 \u7136\u800C\uFF0C\u5BF9\u4E8E\u5E8F\u5217\u5206\u7C7B\uFF0C\u6807\u51C6\u7684 Keras \u635F\u5931\u51FD\u6570\u53EF\u4EE5\u6B63\u5E38\u5DE5\u4F5C\uFF0C\u6240\u4EE5\u6211\u4EEC\u5C06\u5728\u8FD9\u91CC\u4F7F\u7528\u5B83\u3002")},l(_){f=p(_,"P",{});var h=i(f);b=o(h,"\u8BF7\u6CE8\u610F\u{1F917} Transformers \u6A21\u578B\u5177\u6709\u5927\u591A\u6570 Keras \u6A21\u578B\u6240\u6CA1\u6709\u7684\u7279\u6B8A\u80FD\u529B\u2014\u2014\u5B83\u4EEC\u53EF\u4EE5\u81EA\u52A8\u4F7F\u7528\u5185\u90E8\u8BA1\u7B97\u7684loss\u3002 \u5982\u679C\u60A8\u6CA1\u6709\u5728 "),u=p(h,"CODE",{});var v=i(u);k=o(v,"compile()"),v.forEach(s),$=o(h," \u4E2D\u8BBE\u7F6E\u635F\u5931\u51FD\u6570\uFF0C\u4ED6\u4EEC\u5C06\u9ED8\u8BA4\u4F7F\u7528\u5185\u90E8\u8BA1\u7B97\u7684\u635F\u5931\u3002 \u8BF7\u6CE8\u610F\uFF0C\u8981\u4F7F\u7528\u5185\u90E8\u635F\u5931\uFF0C\u60A8\u9700\u8981\u5C06\u6807\u7B7E\u4F5C\u4E3A\u8F93\u5165\u7684\u4E00\u90E8\u5206\u4F20\u9012\uFF0C\u800C\u4E0D\u662F\u4F5C\u4E3A\u5355\u72EC\u7684\u6807\u7B7E\uFF08\u8FD9\u662F\u5728 Keras \u6A21\u578B\u4E2D\u4F7F\u7528\u6807\u7B7E\u7684\u6B63\u5E38\u65B9\u5F0F\uFF09\u3002 \u60A8\u5C06\u5728\u8BFE\u7A0B\u7684\u7B2C 2 \u90E8\u5206\u4E2D\u770B\u5230\u8FD9\u65B9\u9762\u7684\u793A\u4F8B\uFF0C\u5176\u4E2D\u5B9A\u4E49\u6B63\u786E\u7684\u635F\u5931\u51FD\u6570\u53EF\u80FD\u5F88\u68D8\u624B\u3002 \u7136\u800C\uFF0C\u5BF9\u4E8E\u5E8F\u5217\u5206\u7C7B\uFF0C\u6807\u51C6\u7684 Keras \u635F\u5931\u51FD\u6570\u53EF\u4EE5\u6B63\u5E38\u5DE5\u4F5C\uFF0C\u6240\u4EE5\u6211\u4EEC\u5C06\u5728\u8FD9\u91CC\u4F7F\u7528\u5B83\u3002"),h.forEach(s)},m(_,h){r(_,f,h),t(f,b),t(f,u),t(u,k),t(f,$)},d(_){_&&s(f)}}}function Pa(K){let f,b,u,k,$,_,h,v;return{c(){f=n("p"),b=l("\u8BF7\u6CE8\u610F\u8FD9\u91CC\u6709\u4E00\u4E2A\u975E\u5E38\u5E38\u89C1\u7684\u9677\u9631\u2014\u2014\u4F60\u53EA\u662F"),u=n("em"),k=l("\u53EF\u4EE5"),$=l("\u5C06\u635F\u5931\u7684\u540D\u79F0\u4F5C\u4E3A\u5B57\u7B26\u4E32\u4F20\u9012\u7ED9 Keras\uFF0C\u4F46\u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0CKeras \u4F1A\u5047\u8BBE\u4F60\u5DF2\u7ECF\u5BF9\u8F93\u51FA\u5E94\u7528\u4E86 softmax\u3002 \u7136\u800C\uFF0C\u8BB8\u591A\u6A21\u578B\u5728\u5E94\u7528 softmax \u4E4B\u524D\u5C31\u8F93\u51FA\uFF0C\u4E5F\u79F0\u4E3A "),_=n("em"),h=l("logits"),v=l("\u3002 \u6211\u4EEC\u9700\u8981\u544A\u8BC9\u635F\u5931\u51FD\u6570\u6211\u4EEC\u7684\u6A21\u578B\u662F\u5426\u7ECF\u8FC7\u4E86softmax\uFF0C\u552F\u4E00\u7684\u65B9\u6CD5\u662F\u76F4\u63A5\u8C03\u7528\u5B83\uFF0C\u800C\u4E0D\u662F\u7528\u5B57\u7B26\u4E32\u7684\u540D\u79F0\u3002")},l(E){f=p(E,"P",{});var d=i(f);b=o(d,"\u8BF7\u6CE8\u610F\u8FD9\u91CC\u6709\u4E00\u4E2A\u975E\u5E38\u5E38\u89C1\u7684\u9677\u9631\u2014\u2014\u4F60\u53EA\u662F"),u=p(d,"EM",{});var D=i(u);k=o(D,"\u53EF\u4EE5"),D.forEach(s),$=o(d,"\u5C06\u635F\u5931\u7684\u540D\u79F0\u4F5C\u4E3A\u5B57\u7B26\u4E32\u4F20\u9012\u7ED9 Keras\uFF0C\u4F46\u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0CKeras \u4F1A\u5047\u8BBE\u4F60\u5DF2\u7ECF\u5BF9\u8F93\u51FA\u5E94\u7528\u4E86 softmax\u3002 \u7136\u800C\uFF0C\u8BB8\u591A\u6A21\u578B\u5728\u5E94\u7528 softmax \u4E4B\u524D\u5C31\u8F93\u51FA\uFF0C\u4E5F\u79F0\u4E3A "),_=p(d,"EM",{});var z=i(_);h=o(z,"logits"),z.forEach(s),v=o(d,"\u3002 \u6211\u4EEC\u9700\u8981\u544A\u8BC9\u635F\u5931\u51FD\u6570\u6211\u4EEC\u7684\u6A21\u578B\u662F\u5426\u7ECF\u8FC7\u4E86softmax\uFF0C\u552F\u4E00\u7684\u65B9\u6CD5\u662F\u76F4\u63A5\u8C03\u7528\u5B83\uFF0C\u800C\u4E0D\u662F\u7528\u5B57\u7B26\u4E32\u7684\u540D\u79F0\u3002"),d.forEach(s)},m(E,d){r(E,f,d),t(f,b),t(f,u),t(u,k),t(f,$),t(f,_),t(_,h),t(f,v)},d(E){E&&s(f)}}}function za(K){let f,b,u,k,$,_,h,v;return{c(){f=n("p"),b=l("\u{1F917} Transformers \u5E93\u8FD8\u6709\u4E00\u4E2A "),u=n("code"),k=l("create_optimizer()"),$=l(" \u51FD\u6570\uFF0C\u5B83\u5C06\u521B\u5EFA\u4E00\u4E2A\u5177\u6709\u5B66\u4E60\u7387\u8870\u51CF\u7684 "),_=n("code"),h=l("AdamW"),v=l(" \u4F18\u5316\u5668\u3002 \u8FD9\u662F\u4E00\u4E2A\u4FBF\u6377\u7684\u65B9\u5F0F\uFF0C\u60A8\u5C06\u5728\u672C\u8BFE\u7A0B\u7684\u540E\u7EED\u90E8\u5206\u4E2D\u8BE6\u7EC6\u4E86\u89E3\u3002")},l(E){f=p(E,"P",{});var d=i(f);b=o(d,"\u{1F917} Transformers \u5E93\u8FD8\u6709\u4E00\u4E2A "),u=p(d,"CODE",{});var D=i(u);k=o(D,"create_optimizer()"),D.forEach(s),$=o(d," \u51FD\u6570\uFF0C\u5B83\u5C06\u521B\u5EFA\u4E00\u4E2A\u5177\u6709\u5B66\u4E60\u7387\u8870\u51CF\u7684 "),_=p(d,"CODE",{});var z=i(_);h=o(z,"AdamW"),z.forEach(s),v=o(d," \u4F18\u5316\u5668\u3002 \u8FD9\u662F\u4E00\u4E2A\u4FBF\u6377\u7684\u65B9\u5F0F\uFF0C\u60A8\u5C06\u5728\u672C\u8BFE\u7A0B\u7684\u540E\u7EED\u90E8\u5206\u4E2D\u8BE6\u7EC6\u4E86\u89E3\u3002"),d.forEach(s)},m(E,d){r(E,f,d),t(f,b),t(f,u),t(u,k),t(f,$),t(f,_),t(_,h),t(f,v)},d(E){E&&s(f)}}}function Ta(K){let f,b,u,k,$,_,h,v,E,d,D;return{c(){f=n("p"),b=l("\u{1F4A1} \u5982\u679C\u60A8\u60F3\u5728\u8BAD\u7EC3\u671F\u95F4\u81EA\u52A8\u5C06\u6A21\u578B\u4E0A\u4F20\u5230 Hub\uFF0C\u60A8\u53EF\u4EE5\u5728 "),u=n("code"),k=l("model.fit()"),$=l(" \u65B9\u6CD5\u4E2D\u4F20\u9012 "),_=n("code"),h=l("PushToHubCallback"),v=l("\u3002 \u6211\u4EEC\u5C06\u5728 "),E=n("a"),d=l("\u7B2C\u56DB\u7AE0"),D=l(" \u4E2D\u8FDB\u884C\u4ECB\u7ECD"),this.h()},l(z){f=p(z,"P",{});var P=i(f);b=o(P,"\u{1F4A1} \u5982\u679C\u60A8\u60F3\u5728\u8BAD\u7EC3\u671F\u95F4\u81EA\u52A8\u5C06\u6A21\u578B\u4E0A\u4F20\u5230 Hub\uFF0C\u60A8\u53EF\u4EE5\u5728 "),u=p(P,"CODE",{});var Q=i(u);k=o(Q,"model.fit()"),Q.forEach(s),$=o(P," \u65B9\u6CD5\u4E2D\u4F20\u9012 "),_=p(P,"CODE",{});var F=i(_);h=o(F,"PushToHubCallback"),F.forEach(s),v=o(P,"\u3002 \u6211\u4EEC\u5C06\u5728 "),E=p(P,"A",{href:!0});var ke=i(E);d=o(ke,"\u7B2C\u56DB\u7AE0"),ke.forEach(s),D=o(P," \u4E2D\u8FDB\u884C\u4ECB\u7ECD"),P.forEach(s),this.h()},h(){T(E,"href","/course/chapter4/3")},m(z,P){r(z,f,P),t(f,b),t(f,u),t(u,k),t(f,$),t(f,_),t(_,h),t(f,v),t(f,E),t(E,d),t(f,D)},d(z){z&&s(f)}}}function Aa(K){let f,b,u,k,$,_,h,v,E,d,D,z,P,Q,F,ke,De,Us,Gs,X,Hs,Rs,Qe,ve,Bs,Xe,Z,Ze,ee,Ls,es,Ee,Ns,ss,se,ts,we,Is,as,te,ls,O,Ws,je,Ys,Js,Fe,Vs,Qs,os,ae,rs,B,Xs,ye,Zs,et,ns,U,st,Se,tt,at,xe,lt,ot,ps,L,is,le,fs,N,ms,oe,rt,cs,re,us,I,nt,Ke,pt,it,_s,A,ft,Me,mt,ct,Oe,ut,_t,Ue,dt,$t,Ge,ht,bt,ds,ne,$s,W,hs,Ce,kt,bs,pe,ks,qe,vt,vs,ie,Es,Y,ws,fe,Et,js,me,ys,G,wt,He,jt,yt,Re,Ct,qt,Cs,ce,qs,ge,gt,gs,ue,Ps,_e,zs,S,Pt,Be,zt,Tt,Le,At,Dt,Ne,Ft,St,Ts,de,As,$e,Ds,x,xt,he,Kt,Mt,Ie,Ot,Ut,We,Gt,Ht,Fs,Pe,Rt,Ss;return u=new qa({props:{fw:K[0]}}),v=new ya({}),P=new Ca({props:{chapter:3,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/zh-CN/chapter3/section3_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/zh-CN/chapter3/section3_tf.ipynb"}]}}),Z=new M({props:{code:`from datasets import load_dataset
from transformers import AutoTokenizer, DataCollatorWithPadding
import numpy as np

raw_datasets = load_dataset("glue", "mrpc")
checkpoint = "bert-base-uncased"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)


def tokenize_function(example):
    return tokenizer(example["sentence1"], example["sentence2"], truncation=True)


tokenized_datasets = raw_datasets.map(tokenize_function, batched=True)

data_collator = DataCollatorWithPadding(tokenizer=tokenizer, return_tensors="tf")

tf_train_dataset = tokenized_datasets["train"].to_tf_dataset(
    columns=["attention_mask", "input_ids", "token_type_ids"],
    label_cols=["labels"],
    shuffle=True,
    collate_fn=data_collator,
    batch_size=8,
)

tf_validation_dataset = tokenized_datasets["validation"].to_tf_dataset(
    columns=["attention_mask", "input_ids", "token_type_ids"],
    label_cols=["labels"],
    shuffle=False,
    collate_fn=data_collator,
    batch_size=8,
)`,highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, DataCollatorWithPadding
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

raw_datasets = load_dataset(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
checkpoint = <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)


<span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_function</span>(<span class="hljs-params">example</span>):
    <span class="hljs-keyword">return</span> tokenizer(example[<span class="hljs-string">&quot;sentence1&quot;</span>], example[<span class="hljs-string">&quot;sentence2&quot;</span>], truncation=<span class="hljs-literal">True</span>)


tokenized_datasets = raw_datasets.<span class="hljs-built_in">map</span>(tokenize_function, batched=<span class="hljs-literal">True</span>)

data_collator = DataCollatorWithPadding(tokenizer=tokenizer, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)

tf_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].to_tf_dataset(
    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;token_type_ids&quot;</span>],
    label_cols=[<span class="hljs-string">&quot;labels&quot;</span>],
    shuffle=<span class="hljs-literal">True</span>,
    collate_fn=data_collator,
    batch_size=<span class="hljs-number">8</span>,
)

tf_validation_dataset = tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>].to_tf_dataset(
    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;token_type_ids&quot;</span>],
    label_cols=[<span class="hljs-string">&quot;labels&quot;</span>],
    shuffle=<span class="hljs-literal">False</span>,
    collate_fn=data_collator,
    batch_size=<span class="hljs-number">8</span>,
)`}}),se=new Os({props:{id:"rnTGBy2ax1c"}}),te=new Os({props:{id:"AUozVp78dhk"}}),ae=new M({props:{code:`from transformers import TFAutoModelForSequenceClassification

model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification

model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=<span class="hljs-number">2</span>)`}}),L=new Ms({props:{$$slots:{default:[ga]},$$scope:{ctx:K}}}),le=new M({props:{code:`from tensorflow.keras.losses import SparseCategoricalCrossentropy

model.compile(
    optimizer="adam",
    loss=SparseCategoricalCrossentropy(from_logits=True),
    metrics=["accuracy"],
)
model.fit(
    tf_train_dataset,
    validation_data=tf_validation_dataset,
)`,highlighted:`<span class="hljs-keyword">from</span> tensorflow.keras.losses <span class="hljs-keyword">import</span> SparseCategoricalCrossentropy

model.<span class="hljs-built_in">compile</span>(
    optimizer=<span class="hljs-string">&quot;adam&quot;</span>,
    loss=SparseCategoricalCrossentropy(from_logits=<span class="hljs-literal">True</span>),
    metrics=[<span class="hljs-string">&quot;accuracy&quot;</span>],
)
model.fit(
    tf_train_dataset,
    validation_data=tf_validation_dataset,
)`}}),N=new Ms({props:{warning:!0,$$slots:{default:[Pa]},$$scope:{ctx:K}}}),re=new Os({props:{id:"cpzq6ESSM5c"}}),ne=new M({props:{code:`from tensorflow.keras.optimizers.schedules import PolynomialDecay

batch_size = 8
num_epochs = 3
# \u8BAD\u7EC3\u6B65\u6570\u662F\u6570\u636E\u96C6\u4E2D\u7684\u6837\u672C\u6570\u9664\u4EE5batch size\u518D\u4E58\u4EE5 epoch\u3002
# \u6CE8\u610F\u8FD9\u91CC\u7684tf_train_dataset\u662F\u4E00\u4E2A\u8F6C\u5316\u4E3Abatch\u540E\u7684 tf.data.Dataset\uFF0C
# \u4E0D\u662F\u539F\u6765\u7684 Hugging Face Dataset\uFF0C\u6240\u4EE5\u5B83\u7684 len() \u5DF2\u7ECF\u662F num_samples // batch_size\u3002
num_train_steps = len(tf_train_dataset) * num_epochs
lr_scheduler = PolynomialDecay(
    initial_learning_rate=5e-5, end_learning_rate=0.0, decay_steps=num_train_steps
)
from tensorflow.keras.optimizers import Adam

opt = Adam(learning_rate=lr_scheduler)`,highlighted:`<span class="hljs-keyword">from</span> tensorflow.keras.optimizers.schedules <span class="hljs-keyword">import</span> PolynomialDecay

batch_size = <span class="hljs-number">8</span>
num_epochs = <span class="hljs-number">3</span>
<span class="hljs-comment"># \u8BAD\u7EC3\u6B65\u6570\u662F\u6570\u636E\u96C6\u4E2D\u7684\u6837\u672C\u6570\u9664\u4EE5batch size\u518D\u4E58\u4EE5 epoch\u3002</span>
<span class="hljs-comment"># \u6CE8\u610F\u8FD9\u91CC\u7684tf_train_dataset\u662F\u4E00\u4E2A\u8F6C\u5316\u4E3Abatch\u540E\u7684 tf.data.Dataset\uFF0C</span>
<span class="hljs-comment"># \u4E0D\u662F\u539F\u6765\u7684 Hugging Face Dataset\uFF0C\u6240\u4EE5\u5B83\u7684 len() \u5DF2\u7ECF\u662F num_samples // batch_size\u3002</span>
num_train_steps = <span class="hljs-built_in">len</span>(tf_train_dataset) * num_epochs
lr_scheduler = PolynomialDecay(
    initial_learning_rate=<span class="hljs-number">5e-5</span>, end_learning_rate=<span class="hljs-number">0.0</span>, decay_steps=num_train_steps
)
<span class="hljs-keyword">from</span> tensorflow.keras.optimizers <span class="hljs-keyword">import</span> Adam

opt = Adam(learning_rate=lr_scheduler)`}}),W=new Ms({props:{$$slots:{default:[za]},$$scope:{ctx:K}}}),pe=new M({props:{code:`import tensorflow as tf

model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
model.compile(optimizer=opt, loss=loss, metrics=["accuracy"])`,highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=<span class="hljs-number">2</span>)
loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=<span class="hljs-literal">True</span>)
model.<span class="hljs-built_in">compile</span>(optimizer=opt, loss=loss, metrics=[<span class="hljs-string">&quot;accuracy&quot;</span>])`}}),ie=new M({props:{code:"model.fit(tf_train_dataset, validation_data=tf_validation_dataset, epochs=3)",highlighted:'model.fit(tf_train_dataset, validation_data=tf_validation_dataset, epochs=<span class="hljs-number">3</span>)'}}),Y=new Ms({props:{$$slots:{default:[Ta]},$$scope:{ctx:K}}}),me=new Os({props:{id:"nx10eh4CoOs"}}),ce=new M({props:{code:'preds = model.predict(tf_validation_dataset)["logits"]',highlighted:'preds = model.predict(tf_validation_dataset)[<span class="hljs-string">&quot;logits&quot;</span>]'}}),ue=new M({props:{code:`class_preds = np.argmax(preds, axis=1)
print(preds.shape, class_preds.shape)`,highlighted:`class_preds = np.argmax(preds, axis=<span class="hljs-number">1</span>)
<span class="hljs-built_in">print</span>(preds.shape, class_preds.shape)`}}),_e=new M({props:{code:"(408, 2) (408,)",highlighted:'(<span class="hljs-number">408</span>, <span class="hljs-number">2</span>) (<span class="hljs-number">408</span>,)'}}),de=new M({props:{code:`import evaluate

metric = evaluate.load("glue", "mrpc")
metric.compute(predictions=class_preds, references=raw_datasets["validation"]["label"])`,highlighted:`<span class="hljs-keyword">import</span> evaluate

metric = evaluate.load(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
metric.compute(predictions=class_preds, references=raw_datasets[<span class="hljs-string">&quot;validation&quot;</span>][<span class="hljs-string">&quot;label&quot;</span>])`}}),$e=new M({props:{code:"{'accuracy': 0.8578431372549019, 'f1': 0.8996539792387542}",highlighted:'{<span class="hljs-string">&#x27;accuracy&#x27;</span>: <span class="hljs-number">0.8578431372549019</span>, <span class="hljs-string">&#x27;f1&#x27;</span>: <span class="hljs-number">0.8996539792387542</span>}'}}),{c(){f=n("meta"),b=m(),w(u.$$.fragment),k=m(),$=n("h1"),_=n("a"),h=n("span"),w(v.$$.fragment),E=m(),d=n("span"),D=l("\u4F7F\u7528 Keras \u5FAE\u8C03\u4E00\u4E2A\u6A21\u578B"),z=m(),w(P.$$.fragment),Q=m(),F=n("p"),ke=l("\u5B8C\u6210\u4E0A\u4E00\u8282\u4E2D\u7684\u6240\u6709\u6570\u636E\u9884\u5904\u7406\u5DE5\u4F5C\u540E\uFF0C\u60A8\u53EA\u5269\u4E0B\u6700\u540E\u7684\u51E0\u4E2A\u6B65\u9AA4\u6765\u8BAD\u7EC3\u6A21\u578B\u3002 \u4F46\u662F\u8BF7\u6CE8\u610F\uFF0C"),De=n("code"),Us=l("model.fit()"),Gs=l(" \u547D\u4EE4\u5728 CPU \u4E0A\u8FD0\u884C\u4F1A\u975E\u5E38\u7F13\u6162\u3002 \u5982\u679C\u60A8\u6CA1\u6709GPU\uFF0C\u5219\u53EF\u4EE5\u5728 "),X=n("a"),Hs=l("Google Colab"),Rs=l(" \u4E0A\u4F7F\u7528\u514D\u8D39\u7684 GPU \u6216 TPU(\u9700\u8981\u68AF\u5B50)\u3002"),Qe=m(),ve=n("p"),Bs=l("\u8FD9\u4E00\u8282\u7684\u4EE3\u7801\u793A\u4F8B\u5047\u8BBE\u60A8\u5DF2\u7ECF\u6267\u884C\u4E86\u4E0A\u4E00\u8282\u4E2D\u7684\u4EE3\u7801\u793A\u4F8B\u3002 \u4E0B\u9762\u4E00\u4E2A\u7B80\u77ED\u7684\u6458\u8981\uFF0C\u5305\u542B\u4E86\u5728\u5F00\u59CB\u5B66\u4E60\u8FD9\u4E00\u8282\u4E4B\u524D\u60A8\u9700\u8981\u7684\u6267\u884C\u7684\u4EE3\u7801\uFF1A"),Xe=m(),w(Z.$$.fragment),Ze=m(),ee=n("h3"),Ls=l("\u8BAD\u7EC3\u6A21\u578B"),es=m(),Ee=n("p"),Ns=l("\u4ECE\u{1F917} Transformers \u5BFC\u5165\u7684 TensorFlow \u6A21\u578B\u5DF2\u7ECF\u662F Keras \u6A21\u578B\u3002 \u4E0B\u9762\u7684\u89C6\u9891\u662F\u5BF9 Keras \u7684\u7B80\u77ED\u4ECB\u7ECD\u3002"),ss=m(),w(se.$$.fragment),ts=m(),we=n("p"),Is=l("\u8FD9\u610F\u5473\u7740\uFF0C\u4E00\u65E6\u6211\u4EEC\u6709\u4E86\u6570\u636E\uFF0C\u5C31\u9700\u8981\u5F88\u5C11\u7684\u5DE5\u4F5C\u5C31\u53EF\u4EE5\u5F00\u59CB\u5BF9\u5176\u8FDB\u884C\u8BAD\u7EC3\u3002"),as=m(),w(te.$$.fragment),ls=m(),O=n("p"),Ws=l("\u548C"),je=n("a"),Ys=l("\u7B2C\u4E8C\u7AE0"),Js=l("\u4F7F\u7528\u7684\u65B9\u6CD5\u4E00\u6837, \u6211\u4EEC\u5C06\u4F7F\u7528\u4E8C\u5206\u7C7B\u7684 "),Fe=n("code"),Vs=l("TFAutoModelForSequenceClassification"),Qs=l("\u7C7B:"),os=m(),w(ae.$$.fragment),rs=m(),B=n("p"),Xs=l("\u60A8\u4F1A\u6CE8\u610F\u5230\uFF0C\u4E0E "),ye=n("a"),Zs=l("\u7B2C\u4E8C\u7AE0"),et=l(" \u4E0D\u540C\u7684\u662F\uFF0C\u60A8\u5728\u5B9E\u4F8B\u5316\u6B64\u9884\u8BAD\u7EC3\u6A21\u578B\u540E\u4F1A\u6536\u5230\u8B66\u544A\u3002 \u8FD9\u662F\u56E0\u4E3A BERT \u6CA1\u6709\u5BF9\u53E5\u5B50\u5BF9\u8FDB\u884C\u5206\u7C7B\u8FDB\u884C\u9884\u8BAD\u7EC3\uFF0C\u6240\u4EE5\u9884\u8BAD\u7EC3\u6A21\u578B\u7684 head \u5DF2\u7ECF\u88AB\u4E22\u5F03\uFF0C\u800C\u662F\u63D2\u5165\u4E86\u4E00\u4E2A\u9002\u5408\u5E8F\u5217\u5206\u7C7B\u7684\u65B0 head\u3002 \u8B66\u544A\u8868\u660E\u4E00\u4E9B\u6743\u91CD\u6CA1\u6709\u4F7F\u7528\uFF08\u5BF9\u5E94\u4E8E\u4E22\u5F03\u7684\u9884\u8BAD\u7EC3\u5934\uFF09\uFF0C\u800C\u5176\u4ED6\u4E00\u4E9B\u6743\u91CD\u662F\u968F\u673A\u521D\u59CB\u5316\u7684\uFF08\u65B0\u5934\u7684\u6743\u91CD\uFF09\u3002 \u6700\u540E\u9F13\u52B1\u60A8\u8BAD\u7EC3\u6A21\u578B\uFF0C\u8FD9\u6B63\u662F\u6211\u4EEC\u73B0\u5728\u8981\u505A\u7684\u3002"),ns=m(),U=n("p"),st=l("\u8981\u5728\u6211\u4EEC\u7684\u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\u6A21\u578B\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u5728\u6211\u4EEC\u7684\u6A21\u578B\u4E0A\u8C03\u7528 "),Se=n("code"),tt=l("compile()"),at=l(" \u65B9\u6CD5\uFF0C\u7136\u540E\u5C06\u6211\u4EEC\u7684\u6570\u636E\u4F20\u9012\u7ED9 "),xe=n("code"),lt=l("fit()"),ot=l(" \u65B9\u6CD5\u3002 \u8FD9\u5C06\u542F\u52A8\u5FAE\u8C03\u8FC7\u7A0B\uFF08\u5728 GPU \u4E0A\u5E94\u8BE5\u9700\u8981\u51E0\u5206\u949F\uFF09\u5E76\u8F93\u51FA\u8BAD\u7EC3loss\uFF0C\u4EE5\u53CA\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u7684\u9A8C\u8BC1loss\u3002"),ps=m(),w(L.$$.fragment),is=m(),w(le.$$.fragment),fs=m(),w(N.$$.fragment),ms=m(),oe=n("h3"),rt=l("\u63D0\u5347\u8BAD\u7EC3\u7684\u6548\u679C"),cs=m(),w(re.$$.fragment),us=m(),I=n("p"),nt=l("\u5982\u679C\u60A8\u5C1D\u8BD5\u4E0A\u9762\u7684\u4EE3\u7801\uFF0C\u5B83\u80AF\u5B9A\u4F1A\u8FD0\u884C\uFF0C\u4F46\u60A8\u4F1A\u53D1\u73B0loss\u53EA\u662F\u7F13\u6162\u6216\u96F6\u661F\u5730\u4E0B\u964D\u3002 \u4E3B\u8981\u539F\u56E0\u662F"),Ke=n("em"),pt=l("\u5B66\u4E60\u7387"),it=l("\u3002 \u4E0Eloss\u4E00\u6837\uFF0C\u5F53\u6211\u4EEC\u5C06\u4F18\u5316\u5668\u7684\u540D\u79F0\u4F5C\u4E3A\u5B57\u7B26\u4E32\u4F20\u9012\u7ED9 Keras \u65F6\uFF0CKeras \u4F1A\u521D\u59CB\u5316\u8BE5\u4F18\u5316\u5668\u5177\u6709\u6240\u6709\u53C2\u6570\u7684\u9ED8\u8BA4\u503C\uFF0C\u5305\u62EC\u5B66\u4E60\u7387\u3002 \u4F46\u662F\uFF0C\u6839\u636E\u957F\u671F\u7ECF\u9A8C\uFF0C\u6211\u4EEC\u77E5\u9053Transformer \u6A21\u578B\u66F4\u9002\u5408\u4F7F\u7528\u6BD4 Adam \u7684\u9ED8\u8BA4\u503C\uFF081e-3\uFF09\u4E5F\u5199\u6210\u4E3A 10 \u7684 -3 \u6B21\u65B9\uFF0C\u6216 0.001\uFF0C\u4F4E\u5F97\u591A\u7684\u5B66\u4E60\u7387\u3002 5e-5 (0.00005) \u6BD4\u9ED8\u8BA4\u503C\u5927\u7EA6\u4F4E 20 \u500D\uFF0C\u662F\u4E00\u4E2A\u66F4\u597D\u7684\u8D77\u70B9\u3002"),_s=m(),A=n("p"),ft=l("\u9664\u4E86\u964D\u4F4E\u5B66\u4E60\u7387\uFF0C\u6211\u4EEC\u8FD8\u6709\u7B2C\u4E8C\u4E2A\u6280\u5DE7\uFF1A\u6211\u4EEC\u53EF\u4EE5\u6162\u6162\u964D\u4F4E\u5B66\u4E60\u7387\u3002\u5728\u8BAD\u7EC3\u8FC7\u7A0B\u4E2D\u3002 \u5728\u6587\u732E\u4E2D\uFF0C\u60A8\u6709\u65F6\u4F1A\u770B\u5230\u8FD9\u88AB\u79F0\u4E3A "),Me=n("em"),mt=l("decaying"),ct=l(" \u6216 "),Oe=n("em"),ut=l("annealing"),_t=l("\u5B66\u4E60\u7387\u3002 \u5728 Keras \u4E2D\uFF0C\u6700\u597D\u7684\u65B9\u6CD5\u662F\u4F7F\u7528 "),Ue=n("em"),dt=l("learning rate scheduler"),$t=l("\u3002 \u4E00\u4E2A\u597D\u7528\u7684\u662F"),Ge=n("code"),ht=l("PolynomialDecay"),bt=l("\u2014\u2014\u5C3D\u7BA1\u6709\u8FD9\u4E2A\u540D\u5B57\uFF0C\u4F46\u5728\u9ED8\u8BA4\u8BBE\u7F6E\u4E0B\uFF0C\u5B83\u53EA\u662F\u7B80\u5355\u5730\u4ECE\u521D\u59CB\u503C\u7EBF\u6027\u8870\u51CF\u5B66\u4E60\u7387\u503C\u5728\u8BAD\u7EC3\u8FC7\u7A0B\u4E2D\u7684\u6700\u7EC8\u503C\uFF0C\u8FD9\u6B63\u662F\u6211\u4EEC\u60F3\u8981\u7684\u3002\u4F46\u662F\uFF0C \u4E3A\u4E86\u6B63\u786E\u4F7F\u7528\u8C03\u5EA6\u7A0B\u5E8F\uFF0C\u6211\u4EEC\u9700\u8981\u544A\u8BC9\u5B83\u8BAD\u7EC3\u7684\u6B21\u6570\u3002 \u6211\u4EEC\u5C06\u5728\u4E0B\u9762\u4E3A\u5176\u8BA1\u7B97\u201Cnum_train_steps\u201D\u3002"),ds=m(),w(ne.$$.fragment),$s=m(),w(W.$$.fragment),hs=m(),Ce=n("p"),kt=l("\u73B0\u5728\u6211\u4EEC\u6709\u4E86\u5168\u65B0\u7684\u4F18\u5316\u5668\uFF0C\u6211\u4EEC\u53EF\u4EE5\u5C1D\u8BD5\u4F7F\u7528\u5B83\u8FDB\u884C\u8BAD\u7EC3\u3002 \u9996\u5148\uFF0C\u8BA9\u6211\u4EEC\u91CD\u65B0\u52A0\u8F7D\u6A21\u578B\uFF0C\u4EE5\u91CD\u7F6E\u6211\u4EEC\u521A\u521A\u8FDB\u884C\u7684\u8BAD\u7EC3\u8FD0\u884C\u5BF9\u6743\u91CD\u7684\u66F4\u6539\uFF0C\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u65B0\u7684\u4F18\u5316\u5668\u5BF9\u5176\u8FDB\u884C\u7F16\u8BD1\uFF1A"),bs=m(),w(pe.$$.fragment),ks=m(),qe=n("p"),vt=l("\u73B0\u5728\uFF0C\u6211\u4EEC\u518D\u6B21\u8FDB\u884Cfit\uFF1A"),vs=m(),w(ie.$$.fragment),Es=m(),w(Y.$$.fragment),ws=m(),fe=n("h3"),Et=l("\u6A21\u578B\u9884\u6D4B"),js=m(),w(me.$$.fragment),ys=m(),G=n("p"),wt=l("\u8BAD\u7EC3\u548C\u89C2\u5BDF\u7684loss\u4E0B\u964D\u90FD\u975E\u5E38\u597D\uFF0C\u4F46\u662F\u5982\u679C\u6211\u4EEC\u60F3\u4ECE\u8BAD\u7EC3\u540E\u7684\u6A21\u578B\u4E2D\u83B7\u5F97\u8F93\u51FA\uFF0C\u6216\u8005\u8BA1\u7B97\u4E00\u4E9B\u6307\u6807\uFF0C\u6216\u8005\u5728\u751F\u4EA7\u4E2D\u4F7F\u7528\u6A21\u578B\u5462\uFF1F \u4E3A\u6B64\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528"),He=n("code"),jt=l("predict()"),yt=l(" \u65B9\u6CD5\u3002 \u8FD9\u5C06\u8FD4\u56DE\u6A21\u578B\u7684\u8F93\u51FA\u5934\u7684"),Re=n("em"),Ct=l("logits"),qt=l("\u6570\u503C\uFF0C\u6BCF\u4E2A\u7C7B\u4E00\u4E2A\u3002"),Cs=m(),w(ce.$$.fragment),qs=m(),ge=n("p"),gt=l("\u6211\u4EEC\u53EF\u4EE5\u5C06\u8FD9\u4E9B logit \u8F6C\u6362\u4E3A\u6A21\u578B\u7684\u7C7B\u522B\u9884\u6D4B\uFF0C\u65B9\u6CD5\u662F\u4F7F\u7528 argmax \u627E\u5230\u6700\u9AD8\u7684 logit\uFF0C\u5B83\u5BF9\u5E94\u4E8E\u6700\u6709\u53EF\u80FD\u7684\u7C7B\u522B\uFF1A"),gs=m(),w(ue.$$.fragment),Ps=m(),w(_e.$$.fragment),zs=m(),S=n("p"),Pt=l("\u73B0\u5728\uFF0C\u8BA9\u6211\u4EEC\u4F7F\u7528\u8FD9\u4E9B "),Be=n("code"),zt=l("preds"),Tt=l(" \u6765\u8BA1\u7B97\u4E00\u4E9B\u6307\u6807\uFF01 \u6211\u4EEC\u53EF\u4EE5\u50CF\u52A0\u8F7D\u6570\u636E\u96C6\u4E00\u6837\u8F7B\u677E\u5730\u52A0\u8F7D\u4E0E MRPC \u6570\u636E\u96C6\u76F8\u5173\u7684\u6307\u6807\uFF0C\u8FD9\u6B21\u4F7F\u7528\u7684\u662F "),Le=n("code"),At=l("evaluate.load()"),Dt=l(" \u51FD\u6570\u3002 \u8FD4\u56DE\u7684\u5BF9\u8C61\u6709\u4E00\u4E2A "),Ne=n("code"),Ft=l("compute()"),St=l(" \u65B9\u6CD5\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u5B83\u6765\u8FDB\u884C\u5EA6\u91CF\u8BA1\u7B97\uFF1A"),Ts=m(),w(de.$$.fragment),As=m(),w($e.$$.fragment),Ds=m(),x=n("p"),xt=l("\u60A8\u83B7\u5F97\u7684\u786E\u5207\u7ED3\u679C\u53EF\u80FD\u4F1A\u6709\u6240\u4E0D\u540C\uFF0C\u56E0\u4E3A\u6A21\u578B\u5934\u7684\u968F\u673A\u521D\u59CB\u5316\u53EF\u80FD\u4F1A\u6539\u53D8\u5B83\u83B7\u5F97\u7684\u6307\u6807\u3002 \u5728\u8FD9\u91CC\uFF0C\u6211\u4EEC\u53EF\u4EE5\u770B\u5230\u6211\u4EEC\u7684\u6A21\u578B\u5728\u9A8C\u8BC1\u96C6\u4E0A\u7684\u51C6\u786E\u7387\u4E3A 85.78%\uFF0CF1 \u5F97\u5206\u4E3A 89.97\u3002 \u8FD9\u4E9B\u662F\u7528\u4E8E\u8BC4\u4F30 GLUE \u57FA\u51C6\u7684 MRPC \u6570\u636E\u96C6\u7ED3\u679C\u7684\u4E24\u4E2A\u6307\u6807\u3002 "),he=n("a"),Kt=l("BERT \u8BBA\u6587"),Mt=l(" \u4E2D\u7684\u8868\u683C\u62A5\u544A\u4E86\u57FA\u672C\u6A21\u578B\u7684 F1 \u5206\u6570\u4E3A 88.9\u3002 \u90A3\u662F "),Ie=n("code"),Ot=l("uncased"),Ut=l(" \u6A21\u578B\uFF0C\u800C\u6211\u4EEC\u76EE\u524D\u4F7F\u7528\u7684\u662F "),We=n("code"),Gt=l("cased"),Ht=l(" \u6A21\u578B\uFF0C\u8FD9\u89E3\u91CA\u4E86\u4E3A\u4EC0\u4E48\u6211\u4EEC\u4F1A\u83B7\u5F97\u66F4\u597D\u7684\u7ED3\u679C\u3002"),Fs=m(),Pe=n("p"),Rt=l("\u4F7F\u7528 Keras API \u8FDB\u884C\u5FAE\u8C03\u7684\u4ECB\u7ECD\u5230\u6B64\u7ED3\u675F\u3002 \u7B2C 7 \u7AE0\u5C06\u7ED9\u51FA\u5BF9\u5927\u591A\u6570\u5E38\u89C1 NLP \u4EFB\u52A1\u6267\u884C\u6B64\u64CD\u4F5C\u7684\u793A\u4F8B\u3002\u5982\u679C\u60A8\u60F3\u5728 Keras API \u4E0A\u78E8\u7EC3\u81EA\u5DF1\u7684\u6280\u80FD\uFF0C\u8BF7\u5C1D\u8BD5\u4F7F\u7B2C\u4E8C\u8282\u6240\u4F7F\u7528\u7684\u7684\u6570\u636E\u5904\u7406\u5728 GLUE SST-2 \u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\u6A21\u578B\u3002"),this.h()},l(e){const a=wa('[data-svelte="svelte-1phssyn"]',document.head);f=p(a,"META",{name:!0,content:!0}),a.forEach(s),b=c(e),j(u.$$.fragment,e),k=c(e),$=p(e,"H1",{class:!0});var be=i($);_=p(be,"A",{id:!0,class:!0,href:!0});var Ye=i(_);h=p(Ye,"SPAN",{});var Je=i(h);j(v.$$.fragment,Je),Je.forEach(s),Ye.forEach(s),E=c(be),d=p(be,"SPAN",{});var Ve=i(d);D=o(Ve,"\u4F7F\u7528 Keras \u5FAE\u8C03\u4E00\u4E2A\u6A21\u578B"),Ve.forEach(s),be.forEach(s),z=c(e),j(P.$$.fragment,e),Q=c(e),F=p(e,"P",{});var R=i(F);ke=o(R,"\u5B8C\u6210\u4E0A\u4E00\u8282\u4E2D\u7684\u6240\u6709\u6570\u636E\u9884\u5904\u7406\u5DE5\u4F5C\u540E\uFF0C\u60A8\u53EA\u5269\u4E0B\u6700\u540E\u7684\u51E0\u4E2A\u6B65\u9AA4\u6765\u8BAD\u7EC3\u6A21\u578B\u3002 \u4F46\u662F\u8BF7\u6CE8\u610F\uFF0C"),De=p(R,"CODE",{});var Bt=i(De);Us=o(Bt,"model.fit()"),Bt.forEach(s),Gs=o(R," \u547D\u4EE4\u5728 CPU \u4E0A\u8FD0\u884C\u4F1A\u975E\u5E38\u7F13\u6162\u3002 \u5982\u679C\u60A8\u6CA1\u6709GPU\uFF0C\u5219\u53EF\u4EE5\u5728 "),X=p(R,"A",{href:!0,rel:!0});var Lt=i(X);Hs=o(Lt,"Google Colab"),Lt.forEach(s),Rs=o(R," \u4E0A\u4F7F\u7528\u514D\u8D39\u7684 GPU \u6216 TPU(\u9700\u8981\u68AF\u5B50)\u3002"),R.forEach(s),Qe=c(e),ve=p(e,"P",{});var Nt=i(ve);Bs=o(Nt,"\u8FD9\u4E00\u8282\u7684\u4EE3\u7801\u793A\u4F8B\u5047\u8BBE\u60A8\u5DF2\u7ECF\u6267\u884C\u4E86\u4E0A\u4E00\u8282\u4E2D\u7684\u4EE3\u7801\u793A\u4F8B\u3002 \u4E0B\u9762\u4E00\u4E2A\u7B80\u77ED\u7684\u6458\u8981\uFF0C\u5305\u542B\u4E86\u5728\u5F00\u59CB\u5B66\u4E60\u8FD9\u4E00\u8282\u4E4B\u524D\u60A8\u9700\u8981\u7684\u6267\u884C\u7684\u4EE3\u7801\uFF1A"),Nt.forEach(s),Xe=c(e),j(Z.$$.fragment,e),Ze=c(e),ee=p(e,"H3",{id:!0});var It=i(ee);Ls=o(It,"\u8BAD\u7EC3\u6A21\u578B"),It.forEach(s),es=c(e),Ee=p(e,"P",{});var Wt=i(Ee);Ns=o(Wt,"\u4ECE\u{1F917} Transformers \u5BFC\u5165\u7684 TensorFlow \u6A21\u578B\u5DF2\u7ECF\u662F Keras \u6A21\u578B\u3002 \u4E0B\u9762\u7684\u89C6\u9891\u662F\u5BF9 Keras \u7684\u7B80\u77ED\u4ECB\u7ECD\u3002"),Wt.forEach(s),ss=c(e),j(se.$$.fragment,e),ts=c(e),we=p(e,"P",{});var Yt=i(we);Is=o(Yt,"\u8FD9\u610F\u5473\u7740\uFF0C\u4E00\u65E6\u6211\u4EEC\u6709\u4E86\u6570\u636E\uFF0C\u5C31\u9700\u8981\u5F88\u5C11\u7684\u5DE5\u4F5C\u5C31\u53EF\u4EE5\u5F00\u59CB\u5BF9\u5176\u8FDB\u884C\u8BAD\u7EC3\u3002"),Yt.forEach(s),as=c(e),j(te.$$.fragment,e),ls=c(e),O=p(e,"P",{});var ze=i(O);Ws=o(ze,"\u548C"),je=p(ze,"A",{href:!0});var Jt=i(je);Ys=o(Jt,"\u7B2C\u4E8C\u7AE0"),Jt.forEach(s),Js=o(ze,"\u4F7F\u7528\u7684\u65B9\u6CD5\u4E00\u6837, \u6211\u4EEC\u5C06\u4F7F\u7528\u4E8C\u5206\u7C7B\u7684 "),Fe=p(ze,"CODE",{});var Vt=i(Fe);Vs=o(Vt,"TFAutoModelForSequenceClassification"),Vt.forEach(s),Qs=o(ze,"\u7C7B:"),ze.forEach(s),os=c(e),j(ae.$$.fragment,e),rs=c(e),B=p(e,"P",{});var xs=i(B);Xs=o(xs,"\u60A8\u4F1A\u6CE8\u610F\u5230\uFF0C\u4E0E "),ye=p(xs,"A",{href:!0});var Qt=i(ye);Zs=o(Qt,"\u7B2C\u4E8C\u7AE0"),Qt.forEach(s),et=o(xs," \u4E0D\u540C\u7684\u662F\uFF0C\u60A8\u5728\u5B9E\u4F8B\u5316\u6B64\u9884\u8BAD\u7EC3\u6A21\u578B\u540E\u4F1A\u6536\u5230\u8B66\u544A\u3002 \u8FD9\u662F\u56E0\u4E3A BERT \u6CA1\u6709\u5BF9\u53E5\u5B50\u5BF9\u8FDB\u884C\u5206\u7C7B\u8FDB\u884C\u9884\u8BAD\u7EC3\uFF0C\u6240\u4EE5\u9884\u8BAD\u7EC3\u6A21\u578B\u7684 head \u5DF2\u7ECF\u88AB\u4E22\u5F03\uFF0C\u800C\u662F\u63D2\u5165\u4E86\u4E00\u4E2A\u9002\u5408\u5E8F\u5217\u5206\u7C7B\u7684\u65B0 head\u3002 \u8B66\u544A\u8868\u660E\u4E00\u4E9B\u6743\u91CD\u6CA1\u6709\u4F7F\u7528\uFF08\u5BF9\u5E94\u4E8E\u4E22\u5F03\u7684\u9884\u8BAD\u7EC3\u5934\uFF09\uFF0C\u800C\u5176\u4ED6\u4E00\u4E9B\u6743\u91CD\u662F\u968F\u673A\u521D\u59CB\u5316\u7684\uFF08\u65B0\u5934\u7684\u6743\u91CD\uFF09\u3002 \u6700\u540E\u9F13\u52B1\u60A8\u8BAD\u7EC3\u6A21\u578B\uFF0C\u8FD9\u6B63\u662F\u6211\u4EEC\u73B0\u5728\u8981\u505A\u7684\u3002"),xs.forEach(s),ns=c(e),U=p(e,"P",{});var Te=i(U);st=o(Te,"\u8981\u5728\u6211\u4EEC\u7684\u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\u6A21\u578B\uFF0C\u6211\u4EEC\u53EA\u9700\u8981\u5728\u6211\u4EEC\u7684\u6A21\u578B\u4E0A\u8C03\u7528 "),Se=p(Te,"CODE",{});var Xt=i(Se);tt=o(Xt,"compile()"),Xt.forEach(s),at=o(Te," \u65B9\u6CD5\uFF0C\u7136\u540E\u5C06\u6211\u4EEC\u7684\u6570\u636E\u4F20\u9012\u7ED9 "),xe=p(Te,"CODE",{});var Zt=i(xe);lt=o(Zt,"fit()"),Zt.forEach(s),ot=o(Te," \u65B9\u6CD5\u3002 \u8FD9\u5C06\u542F\u52A8\u5FAE\u8C03\u8FC7\u7A0B\uFF08\u5728 GPU \u4E0A\u5E94\u8BE5\u9700\u8981\u51E0\u5206\u949F\uFF09\u5E76\u8F93\u51FA\u8BAD\u7EC3loss\uFF0C\u4EE5\u53CA\u6BCF\u4E2A epoch \u7ED3\u675F\u65F6\u7684\u9A8C\u8BC1loss\u3002"),Te.forEach(s),ps=c(e),j(L.$$.fragment,e),is=c(e),j(le.$$.fragment,e),fs=c(e),j(N.$$.fragment,e),ms=c(e),oe=p(e,"H3",{id:!0});var ea=i(oe);rt=o(ea,"\u63D0\u5347\u8BAD\u7EC3\u7684\u6548\u679C"),ea.forEach(s),cs=c(e),j(re.$$.fragment,e),us=c(e),I=p(e,"P",{});var Ks=i(I);nt=o(Ks,"\u5982\u679C\u60A8\u5C1D\u8BD5\u4E0A\u9762\u7684\u4EE3\u7801\uFF0C\u5B83\u80AF\u5B9A\u4F1A\u8FD0\u884C\uFF0C\u4F46\u60A8\u4F1A\u53D1\u73B0loss\u53EA\u662F\u7F13\u6162\u6216\u96F6\u661F\u5730\u4E0B\u964D\u3002 \u4E3B\u8981\u539F\u56E0\u662F"),Ke=p(Ks,"EM",{});var sa=i(Ke);pt=o(sa,"\u5B66\u4E60\u7387"),sa.forEach(s),it=o(Ks,"\u3002 \u4E0Eloss\u4E00\u6837\uFF0C\u5F53\u6211\u4EEC\u5C06\u4F18\u5316\u5668\u7684\u540D\u79F0\u4F5C\u4E3A\u5B57\u7B26\u4E32\u4F20\u9012\u7ED9 Keras \u65F6\uFF0CKeras \u4F1A\u521D\u59CB\u5316\u8BE5\u4F18\u5316\u5668\u5177\u6709\u6240\u6709\u53C2\u6570\u7684\u9ED8\u8BA4\u503C\uFF0C\u5305\u62EC\u5B66\u4E60\u7387\u3002 \u4F46\u662F\uFF0C\u6839\u636E\u957F\u671F\u7ECF\u9A8C\uFF0C\u6211\u4EEC\u77E5\u9053Transformer \u6A21\u578B\u66F4\u9002\u5408\u4F7F\u7528\u6BD4 Adam \u7684\u9ED8\u8BA4\u503C\uFF081e-3\uFF09\u4E5F\u5199\u6210\u4E3A 10 \u7684 -3 \u6B21\u65B9\uFF0C\u6216 0.001\uFF0C\u4F4E\u5F97\u591A\u7684\u5B66\u4E60\u7387\u3002 5e-5 (0.00005) \u6BD4\u9ED8\u8BA4\u503C\u5927\u7EA6\u4F4E 20 \u500D\uFF0C\u662F\u4E00\u4E2A\u66F4\u597D\u7684\u8D77\u70B9\u3002"),Ks.forEach(s),_s=c(e),A=p(e,"P",{});var H=i(A);ft=o(H,"\u9664\u4E86\u964D\u4F4E\u5B66\u4E60\u7387\uFF0C\u6211\u4EEC\u8FD8\u6709\u7B2C\u4E8C\u4E2A\u6280\u5DE7\uFF1A\u6211\u4EEC\u53EF\u4EE5\u6162\u6162\u964D\u4F4E\u5B66\u4E60\u7387\u3002\u5728\u8BAD\u7EC3\u8FC7\u7A0B\u4E2D\u3002 \u5728\u6587\u732E\u4E2D\uFF0C\u60A8\u6709\u65F6\u4F1A\u770B\u5230\u8FD9\u88AB\u79F0\u4E3A "),Me=p(H,"EM",{});var ta=i(Me);mt=o(ta,"decaying"),ta.forEach(s),ct=o(H," \u6216 "),Oe=p(H,"EM",{});var aa=i(Oe);ut=o(aa,"annealing"),aa.forEach(s),_t=o(H,"\u5B66\u4E60\u7387\u3002 \u5728 Keras \u4E2D\uFF0C\u6700\u597D\u7684\u65B9\u6CD5\u662F\u4F7F\u7528 "),Ue=p(H,"EM",{});var la=i(Ue);dt=o(la,"learning rate scheduler"),la.forEach(s),$t=o(H,"\u3002 \u4E00\u4E2A\u597D\u7528\u7684\u662F"),Ge=p(H,"CODE",{});var oa=i(Ge);ht=o(oa,"PolynomialDecay"),oa.forEach(s),bt=o(H,"\u2014\u2014\u5C3D\u7BA1\u6709\u8FD9\u4E2A\u540D\u5B57\uFF0C\u4F46\u5728\u9ED8\u8BA4\u8BBE\u7F6E\u4E0B\uFF0C\u5B83\u53EA\u662F\u7B80\u5355\u5730\u4ECE\u521D\u59CB\u503C\u7EBF\u6027\u8870\u51CF\u5B66\u4E60\u7387\u503C\u5728\u8BAD\u7EC3\u8FC7\u7A0B\u4E2D\u7684\u6700\u7EC8\u503C\uFF0C\u8FD9\u6B63\u662F\u6211\u4EEC\u60F3\u8981\u7684\u3002\u4F46\u662F\uFF0C \u4E3A\u4E86\u6B63\u786E\u4F7F\u7528\u8C03\u5EA6\u7A0B\u5E8F\uFF0C\u6211\u4EEC\u9700\u8981\u544A\u8BC9\u5B83\u8BAD\u7EC3\u7684\u6B21\u6570\u3002 \u6211\u4EEC\u5C06\u5728\u4E0B\u9762\u4E3A\u5176\u8BA1\u7B97\u201Cnum_train_steps\u201D\u3002"),H.forEach(s),ds=c(e),j(ne.$$.fragment,e),$s=c(e),j(W.$$.fragment,e),hs=c(e),Ce=p(e,"P",{});var ra=i(Ce);kt=o(ra,"\u73B0\u5728\u6211\u4EEC\u6709\u4E86\u5168\u65B0\u7684\u4F18\u5316\u5668\uFF0C\u6211\u4EEC\u53EF\u4EE5\u5C1D\u8BD5\u4F7F\u7528\u5B83\u8FDB\u884C\u8BAD\u7EC3\u3002 \u9996\u5148\uFF0C\u8BA9\u6211\u4EEC\u91CD\u65B0\u52A0\u8F7D\u6A21\u578B\uFF0C\u4EE5\u91CD\u7F6E\u6211\u4EEC\u521A\u521A\u8FDB\u884C\u7684\u8BAD\u7EC3\u8FD0\u884C\u5BF9\u6743\u91CD\u7684\u66F4\u6539\uFF0C\u7136\u540E\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u65B0\u7684\u4F18\u5316\u5668\u5BF9\u5176\u8FDB\u884C\u7F16\u8BD1\uFF1A"),ra.forEach(s),bs=c(e),j(pe.$$.fragment,e),ks=c(e),qe=p(e,"P",{});var na=i(qe);vt=o(na,"\u73B0\u5728\uFF0C\u6211\u4EEC\u518D\u6B21\u8FDB\u884Cfit\uFF1A"),na.forEach(s),vs=c(e),j(ie.$$.fragment,e),Es=c(e),j(Y.$$.fragment,e),ws=c(e),fe=p(e,"H3",{id:!0});var pa=i(fe);Et=o(pa,"\u6A21\u578B\u9884\u6D4B"),pa.forEach(s),js=c(e),j(me.$$.fragment,e),ys=c(e),G=p(e,"P",{});var Ae=i(G);wt=o(Ae,"\u8BAD\u7EC3\u548C\u89C2\u5BDF\u7684loss\u4E0B\u964D\u90FD\u975E\u5E38\u597D\uFF0C\u4F46\u662F\u5982\u679C\u6211\u4EEC\u60F3\u4ECE\u8BAD\u7EC3\u540E\u7684\u6A21\u578B\u4E2D\u83B7\u5F97\u8F93\u51FA\uFF0C\u6216\u8005\u8BA1\u7B97\u4E00\u4E9B\u6307\u6807\uFF0C\u6216\u8005\u5728\u751F\u4EA7\u4E2D\u4F7F\u7528\u6A21\u578B\u5462\uFF1F \u4E3A\u6B64\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528"),He=p(Ae,"CODE",{});var ia=i(He);jt=o(ia,"predict()"),ia.forEach(s),yt=o(Ae," \u65B9\u6CD5\u3002 \u8FD9\u5C06\u8FD4\u56DE\u6A21\u578B\u7684\u8F93\u51FA\u5934\u7684"),Re=p(Ae,"EM",{});var fa=i(Re);Ct=o(fa,"logits"),fa.forEach(s),qt=o(Ae,"\u6570\u503C\uFF0C\u6BCF\u4E2A\u7C7B\u4E00\u4E2A\u3002"),Ae.forEach(s),Cs=c(e),j(ce.$$.fragment,e),qs=c(e),ge=p(e,"P",{});var ma=i(ge);gt=o(ma,"\u6211\u4EEC\u53EF\u4EE5\u5C06\u8FD9\u4E9B logit \u8F6C\u6362\u4E3A\u6A21\u578B\u7684\u7C7B\u522B\u9884\u6D4B\uFF0C\u65B9\u6CD5\u662F\u4F7F\u7528 argmax \u627E\u5230\u6700\u9AD8\u7684 logit\uFF0C\u5B83\u5BF9\u5E94\u4E8E\u6700\u6709\u53EF\u80FD\u7684\u7C7B\u522B\uFF1A"),ma.forEach(s),gs=c(e),j(ue.$$.fragment,e),Ps=c(e),j(_e.$$.fragment,e),zs=c(e),S=p(e,"P",{});var J=i(S);Pt=o(J,"\u73B0\u5728\uFF0C\u8BA9\u6211\u4EEC\u4F7F\u7528\u8FD9\u4E9B "),Be=p(J,"CODE",{});var ca=i(Be);zt=o(ca,"preds"),ca.forEach(s),Tt=o(J," \u6765\u8BA1\u7B97\u4E00\u4E9B\u6307\u6807\uFF01 \u6211\u4EEC\u53EF\u4EE5\u50CF\u52A0\u8F7D\u6570\u636E\u96C6\u4E00\u6837\u8F7B\u677E\u5730\u52A0\u8F7D\u4E0E MRPC \u6570\u636E\u96C6\u76F8\u5173\u7684\u6307\u6807\uFF0C\u8FD9\u6B21\u4F7F\u7528\u7684\u662F "),Le=p(J,"CODE",{});var ua=i(Le);At=o(ua,"evaluate.load()"),ua.forEach(s),Dt=o(J," \u51FD\u6570\u3002 \u8FD4\u56DE\u7684\u5BF9\u8C61\u6709\u4E00\u4E2A "),Ne=p(J,"CODE",{});var _a=i(Ne);Ft=o(_a,"compute()"),_a.forEach(s),St=o(J," \u65B9\u6CD5\uFF0C\u6211\u4EEC\u53EF\u4EE5\u4F7F\u7528\u5B83\u6765\u8FDB\u884C\u5EA6\u91CF\u8BA1\u7B97\uFF1A"),J.forEach(s),Ts=c(e),j(de.$$.fragment,e),As=c(e),j($e.$$.fragment,e),Ds=c(e),x=p(e,"P",{});var V=i(x);xt=o(V,"\u60A8\u83B7\u5F97\u7684\u786E\u5207\u7ED3\u679C\u53EF\u80FD\u4F1A\u6709\u6240\u4E0D\u540C\uFF0C\u56E0\u4E3A\u6A21\u578B\u5934\u7684\u968F\u673A\u521D\u59CB\u5316\u53EF\u80FD\u4F1A\u6539\u53D8\u5B83\u83B7\u5F97\u7684\u6307\u6807\u3002 \u5728\u8FD9\u91CC\uFF0C\u6211\u4EEC\u53EF\u4EE5\u770B\u5230\u6211\u4EEC\u7684\u6A21\u578B\u5728\u9A8C\u8BC1\u96C6\u4E0A\u7684\u51C6\u786E\u7387\u4E3A 85.78%\uFF0CF1 \u5F97\u5206\u4E3A 89.97\u3002 \u8FD9\u4E9B\u662F\u7528\u4E8E\u8BC4\u4F30 GLUE \u57FA\u51C6\u7684 MRPC \u6570\u636E\u96C6\u7ED3\u679C\u7684\u4E24\u4E2A\u6307\u6807\u3002 "),he=p(V,"A",{href:!0,rel:!0});var da=i(he);Kt=o(da,"BERT \u8BBA\u6587"),da.forEach(s),Mt=o(V," \u4E2D\u7684\u8868\u683C\u62A5\u544A\u4E86\u57FA\u672C\u6A21\u578B\u7684 F1 \u5206\u6570\u4E3A 88.9\u3002 \u90A3\u662F "),Ie=p(V,"CODE",{});var $a=i(Ie);Ot=o($a,"uncased"),$a.forEach(s),Ut=o(V," \u6A21\u578B\uFF0C\u800C\u6211\u4EEC\u76EE\u524D\u4F7F\u7528\u7684\u662F "),We=p(V,"CODE",{});var ha=i(We);Gt=o(ha,"cased"),ha.forEach(s),Ht=o(V," \u6A21\u578B\uFF0C\u8FD9\u89E3\u91CA\u4E86\u4E3A\u4EC0\u4E48\u6211\u4EEC\u4F1A\u83B7\u5F97\u66F4\u597D\u7684\u7ED3\u679C\u3002"),V.forEach(s),Fs=c(e),Pe=p(e,"P",{});var ba=i(Pe);Rt=o(ba,"\u4F7F\u7528 Keras API \u8FDB\u884C\u5FAE\u8C03\u7684\u4ECB\u7ECD\u5230\u6B64\u7ED3\u675F\u3002 \u7B2C 7 \u7AE0\u5C06\u7ED9\u51FA\u5BF9\u5927\u591A\u6570\u5E38\u89C1 NLP \u4EFB\u52A1\u6267\u884C\u6B64\u64CD\u4F5C\u7684\u793A\u4F8B\u3002\u5982\u679C\u60A8\u60F3\u5728 Keras API \u4E0A\u78E8\u7EC3\u81EA\u5DF1\u7684\u6280\u80FD\uFF0C\u8BF7\u5C1D\u8BD5\u4F7F\u7B2C\u4E8C\u8282\u6240\u4F7F\u7528\u7684\u7684\u6570\u636E\u5904\u7406\u5728 GLUE SST-2 \u6570\u636E\u96C6\u4E0A\u5FAE\u8C03\u6A21\u578B\u3002"),ba.forEach(s),this.h()},h(){T(f,"name","hf:doc:metadata"),T(f,"content",JSON.stringify(Da)),T(_,"id","keras"),T(_,"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"),T(_,"href","#keras"),T($,"class","relative group"),T(X,"href","https://colab.research.google.com/"),T(X,"rel","nofollow"),T(ee,"id",""),T(je,"href","/course/chapter2"),T(ye,"href","/course/chapter2"),T(oe,"id",""),T(fe,"id",""),T(he,"href","https://arxiv.org/pdf/1810.04805.pdf"),T(he,"rel","nofollow")},m(e,a){t(document.head,f),r(e,b,a),y(u,e,a),r(e,k,a),r(e,$,a),t($,_),t(_,h),y(v,h,null),t($,E),t($,d),t(d,D),r(e,z,a),y(P,e,a),r(e,Q,a),r(e,F,a),t(F,ke),t(F,De),t(De,Us),t(F,Gs),t(F,X),t(X,Hs),t(F,Rs),r(e,Qe,a),r(e,ve,a),t(ve,Bs),r(e,Xe,a),y(Z,e,a),r(e,Ze,a),r(e,ee,a),t(ee,Ls),r(e,es,a),r(e,Ee,a),t(Ee,Ns),r(e,ss,a),y(se,e,a),r(e,ts,a),r(e,we,a),t(we,Is),r(e,as,a),y(te,e,a),r(e,ls,a),r(e,O,a),t(O,Ws),t(O,je),t(je,Ys),t(O,Js),t(O,Fe),t(Fe,Vs),t(O,Qs),r(e,os,a),y(ae,e,a),r(e,rs,a),r(e,B,a),t(B,Xs),t(B,ye),t(ye,Zs),t(B,et),r(e,ns,a),r(e,U,a),t(U,st),t(U,Se),t(Se,tt),t(U,at),t(U,xe),t(xe,lt),t(U,ot),r(e,ps,a),y(L,e,a),r(e,is,a),y(le,e,a),r(e,fs,a),y(N,e,a),r(e,ms,a),r(e,oe,a),t(oe,rt),r(e,cs,a),y(re,e,a),r(e,us,a),r(e,I,a),t(I,nt),t(I,Ke),t(Ke,pt),t(I,it),r(e,_s,a),r(e,A,a),t(A,ft),t(A,Me),t(Me,mt),t(A,ct),t(A,Oe),t(Oe,ut),t(A,_t),t(A,Ue),t(Ue,dt),t(A,$t),t(A,Ge),t(Ge,ht),t(A,bt),r(e,ds,a),y(ne,e,a),r(e,$s,a),y(W,e,a),r(e,hs,a),r(e,Ce,a),t(Ce,kt),r(e,bs,a),y(pe,e,a),r(e,ks,a),r(e,qe,a),t(qe,vt),r(e,vs,a),y(ie,e,a),r(e,Es,a),y(Y,e,a),r(e,ws,a),r(e,fe,a),t(fe,Et),r(e,js,a),y(me,e,a),r(e,ys,a),r(e,G,a),t(G,wt),t(G,He),t(He,jt),t(G,yt),t(G,Re),t(Re,Ct),t(G,qt),r(e,Cs,a),y(ce,e,a),r(e,qs,a),r(e,ge,a),t(ge,gt),r(e,gs,a),y(ue,e,a),r(e,Ps,a),y(_e,e,a),r(e,zs,a),r(e,S,a),t(S,Pt),t(S,Be),t(Be,zt),t(S,Tt),t(S,Le),t(Le,At),t(S,Dt),t(S,Ne),t(Ne,Ft),t(S,St),r(e,Ts,a),y(de,e,a),r(e,As,a),y($e,e,a),r(e,Ds,a),r(e,x,a),t(x,xt),t(x,he),t(he,Kt),t(x,Mt),t(x,Ie),t(Ie,Ot),t(x,Ut),t(x,We),t(We,Gt),t(x,Ht),r(e,Fs,a),r(e,Pe,a),t(Pe,Rt),Ss=!0},p(e,[a]){const be={};a&1&&(be.fw=e[0]),u.$set(be);const Ye={};a&2&&(Ye.$$scope={dirty:a,ctx:e}),L.$set(Ye);const Je={};a&2&&(Je.$$scope={dirty:a,ctx:e}),N.$set(Je);const Ve={};a&2&&(Ve.$$scope={dirty:a,ctx:e}),W.$set(Ve);const R={};a&2&&(R.$$scope={dirty:a,ctx:e}),Y.$set(R)},i(e){Ss||(C(u.$$.fragment,e),C(v.$$.fragment,e),C(P.$$.fragment,e),C(Z.$$.fragment,e),C(se.$$.fragment,e),C(te.$$.fragment,e),C(ae.$$.fragment,e),C(L.$$.fragment,e),C(le.$$.fragment,e),C(N.$$.fragment,e),C(re.$$.fragment,e),C(ne.$$.fragment,e),C(W.$$.fragment,e),C(pe.$$.fragment,e),C(ie.$$.fragment,e),C(Y.$$.fragment,e),C(me.$$.fragment,e),C(ce.$$.fragment,e),C(ue.$$.fragment,e),C(_e.$$.fragment,e),C(de.$$.fragment,e),C($e.$$.fragment,e),Ss=!0)},o(e){q(u.$$.fragment,e),q(v.$$.fragment,e),q(P.$$.fragment,e),q(Z.$$.fragment,e),q(se.$$.fragment,e),q(te.$$.fragment,e),q(ae.$$.fragment,e),q(L.$$.fragment,e),q(le.$$.fragment,e),q(N.$$.fragment,e),q(re.$$.fragment,e),q(ne.$$.fragment,e),q(W.$$.fragment,e),q(pe.$$.fragment,e),q(ie.$$.fragment,e),q(Y.$$.fragment,e),q(me.$$.fragment,e),q(ce.$$.fragment,e),q(ue.$$.fragment,e),q(_e.$$.fragment,e),q(de.$$.fragment,e),q($e.$$.fragment,e),Ss=!1},d(e){s(f),e&&s(b),g(u,e),e&&s(k),e&&s($),g(v),e&&s(z),g(P,e),e&&s(Q),e&&s(F),e&&s(Qe),e&&s(ve),e&&s(Xe),g(Z,e),e&&s(Ze),e&&s(ee),e&&s(es),e&&s(Ee),e&&s(ss),g(se,e),e&&s(ts),e&&s(we),e&&s(as),g(te,e),e&&s(ls),e&&s(O),e&&s(os),g(ae,e),e&&s(rs),e&&s(B),e&&s(ns),e&&s(U),e&&s(ps),g(L,e),e&&s(is),g(le,e),e&&s(fs),g(N,e),e&&s(ms),e&&s(oe),e&&s(cs),g(re,e),e&&s(us),e&&s(I),e&&s(_s),e&&s(A),e&&s(ds),g(ne,e),e&&s($s),g(W,e),e&&s(hs),e&&s(Ce),e&&s(bs),g(pe,e),e&&s(ks),e&&s(qe),e&&s(vs),g(ie,e),e&&s(Es),g(Y,e),e&&s(ws),e&&s(fe),e&&s(js),g(me,e),e&&s(ys),e&&s(G),e&&s(Cs),g(ce,e),e&&s(qs),e&&s(ge),e&&s(gs),g(ue,e),e&&s(Ps),g(_e,e),e&&s(zs),e&&s(S),e&&s(Ts),g(de,e),e&&s(As),g($e,e),e&&s(Ds),e&&s(x),e&&s(Fs),e&&s(Pe)}}}const Da={local:"keras",sections:[{local:"",title:"\u8BAD\u7EC3\u6A21\u578B"},{local:"",title:"\u63D0\u5347\u8BAD\u7EC3\u7684\u6548\u679C"},{local:"",title:"\u6A21\u578B\u9884\u6D4B"}],title:"\u4F7F\u7528 Keras \u5FAE\u8C03\u4E00\u4E2A\u6A21\u578B"};function Fa(K,f,b){let u="pt";return ja(()=>{const k=new URLSearchParams(window.location.search);b(0,u=k.get("fw")||"pt")}),[u]}class Ra extends ka{constructor(f){super();va(this,f,Fa,Aa,Ea,{})}}export{Ra as default,Da as metadata};
