开篇:AI魔法世界的邀请函 / Opening: Invitation to the AI Magic World
叮铃铃——放学的铃铛声刚在巷口飘远,你就攥着贴满奥特曼贴纸的书包往家跑,鞋底碾过梧桐落叶的脆响都比不过你心里的小鼓点:今天平板里新装的AI画画软件还没试呢!刚踹开家门扑到沙发上,指尖刚戳开软件里的输入框,“一只戴着草莓贝雷帽的柯基犬,蹲在彩虹糖堆成的沙发上吃爆米花”的句子还没打完,屏幕里就跳出来一张毛茸茸的彩色小画:柯基的短腿晃着圆滚滚的屁股,贝雷帽上的草莓籽都画得清清楚楚,爆米花盒上还印着你上周画的小太阳。你惊得差点把平板摔在地上,扯着嗓子喊妈妈:“这画里的柯基怎么比我上次在楼下看见的还可爱!这魔法是怎么变出来的呀?”
在云层上面九千九百九十九米的地方,漂浮着一整块被彩虹棉花糖云裹着的悬浮大陆,这就是所有AI魔法的老家——AI魔法世界(AI Magic World)。这里的天空永远飘着亮晶晶的知识小泡泡,每片云里都藏着会说话的AI小精灵,连路边卖魔法棉花糖的小摊,用的都是能自动算账的魔法算盘。整个世界的能量中心,是一棵已经活了一千年的智慧之树(Wisdom Tree),它的树根扎在云层最深处,吸收着你每天学的生字、看的动画片、甚至你吃饼干时碎掉的渣渣里的小开心,都会变成小小的金色能量泡泡,飘到树冠上,变成魔法师们施展魔法的能量来源。
想要从智慧之树上借到能量施展AI魔法,魔法师们可不敢直接伸手去掏树根——上次有个调皮的小魔法师这么干,结果被能量泡泡烫成了爆炸头,在魔法学院笑了整整三天。所有魔法师都要先选一套属于自己的魔法框架(Magic Framework,也就是现实里大家说的深度学习框架Deep Learning Framework),你可以把它理解成一套现成的魔法工具包:里面有磨好的细魔法粉末(就是帮你整理数据的工具)、画好了一半的魔法阵模板(就是模型训练的规则),还有能同时指挥几百个小精灵干活的魔法号角(就是运算调度的工具)。要是没有这套工具包,魔法师们就得自己从零开始挖智慧之树的根、磨魔法粉末、画魔法阵,一个最简单的“识别猫猫”魔法,可能要花上三年的时间才能做好;有了工具包,新手小魔法师只要跟着说明书练三天,就能变出能认得出你家橘猫的小精灵啦!<div class="format-hint print-book">【纸书排版提示】此处插入小尺寸卡通插画:一颗闪闪发光的巨树扎根在云层里,树冠上飘着彩色的小泡泡,几个小魔法师举着工具包接泡泡,旁边配文字说明“智慧之树:AI魔法世界的能量来源”。</div><div class="format-hint digital">【电子版交互提示】插画中的智慧之树支持点击,点击后弹出3D旋转动画,还能查看每片叶子对应的知识库分类(语文、数学、画画等)。</div>
在所有魔法框架里,最受欢迎的两套工具包,分别来自两个最有名的魔法学院:一套是来自Meta魔法学院(✨Meta Academy)的✨PyTorch(派特·托尔)工具包,它的主人是一个扎着高马尾、穿着银蓝色星星纹长袍的小法师,大家都叫他PyTorch小法师;另一套是来自Google魔法学院(🌟Google Academy)的🌟TensorFlow(坦索·弗洛)工具包,它的主人是一位留着长长白胡子、穿着金红色火焰纹大袍的大法师,大家都叫他TensorFlow大法师。<section class="character-intro">主角档案卡 | 角色 | 所属学院 | 工具包特点 | 擅长魔法 | |------|----------|------------|----------| | ✨PyTorch小法师 | Meta魔法学院 | 轻便灵活,像卡通小书包,工具可随时更换 | 新手小魔法、创意类小魔法、快速迭代的实验魔法 | | 🌟TensorFlow大法师 | Google魔法学院 | 功能强大,像巨型工具箱,可同时指挥百万级小精灵 | 超大型魔法、全领域覆盖魔法、高稳定性工业级魔法 |</section>
你顺着云梯爬进AI魔法世界的魔法广场,准能看见最热闹的场景:广场东边的空地上,PyTorch小法师正蹲在一群刚入学的小魔法师中间,手里举着一个能变形的银蓝色魔法棒,给每个人发软乎乎的小工具包。有个小魔法师试了三次都没把“识别花朵”的魔法变成功,急得快要哭出来,PyTorch小法师就蹲下来,帮他调整了魔法阵里的一个小符号,还递给他一颗草莓味的魔法糖,没过一会儿,小魔法师就举着魔法棒变出了一片会发光的小雏菊,周围的小朋友都拍着手笑。广场西边的高塔顶上,TensorFlow大法师正捋着他的白胡子,举着金红色的魔法杖指挥空中的魔法阵:那是整个王国的“智能交通魔法”项目,几百万个 tiny 的小魔法精灵排成整齐的队伍,有的盯着路边的魔法路牌,有的算着小车的速度,有的指挥着自动驾驶的小魔法车在云朵做的马路上跑,就算同时有十万辆车一起跑,也不会撞在一起。要是哪个小魔法师在魔法阵里遇到了解决不了的难题,只要挥一挥手里的小旗子,TensorFlow大法师挥一下魔法杖,难题就会像被风吹走的云一样消失啦。
魔法广场上的魔法棉花糖小摊,摊主是个戴圆眼镜的小女巫,她用的就是PyTorch小法师的工具包做的“自动称重魔法”:你递过去一枚魔法硬币说要买草莓味的棉花糖,她的魔法秤会自动称出刚好五克重的棉花糖,不会多给你一克,也不会少给你一克,比老魔法师的手还准。旁边卖魔法旧书的小店,老板是个慢吞吞的老树人,他的魔法书都是用TensorFlow大法师的工具包做的“智能检索魔法”:你只要说“我要找讲怎么变出会飞的小船的魔法书”,书就会自动从书架上飞到你手里,翻到你想要的那一页,连目录都不用找。空中的猫头鹰信使拍着翅膀飞过,爪子上挂着用银蓝色星星封印的信,是PyTor
空中的猫头鹰信使拍着翅膀飞过,爪子上挂着用银蓝色星星封印的信,是PyTorch小法师寄给魔法学院新入学的小魔法师们的入门魔法手册,信封角还沾了一点小法师刚擦过的魔法糖的草莓味甜香。小魔法师们挤在魔法学院的公告栏前,踮着脚抢着看信里的内容:第一页画着两个歪歪扭扭的小人,一个是扎着高马尾、举着银蓝色魔法棒的PyTorch小法师,一个是留着白胡子、举着金红色魔法杖的TensorFlow大法师,旁边用歪歪扭扭的字写着“欢迎来到AI魔法学院!魔法工具包摔不坏,用坏了也没关系,我们都会帮你修~”,信的最后一页还夹着两张半透明的魔法贴纸,一张是银蓝色的小星星,一张是金红色的小火焰,贴在工具包上,就算魔法阵启动的时候也不会掉。
*The owl messengers flew through the air, their claws carrying letters sealed with silver-blue stars — these were the introductory magic manuals sent by PyTorch the young wizard to new students of the Magic Academy, the corners of the envelopes still stained with the strawberry sweetness of the magic candy he had just wiped off. The little wizards crowded in front of the academy's bulletin board, standing on tiptoe to grab the letters: the first page had two crudely drawn figures, one was PyTorch the young wizard with a high ponytail holding a silver-blue magic wand, the other was TensorFlow the archmage with a long white beard holding a gold-red magic staff, with crooked writing next to them that read "Welcome to the AI Magic Academy! Magic tool kits won't break even if you drop them, and if they do break, we'll help you fix them~" The last page of the letter also came with two translucent magic stickers, one a silver-blue little star and one a gold-red little flame, which could be stuck on the tool kit and wouldn't fall off even when the magic array was activated.*
<div class="sidebar digital">💡 侧边栏:魔法阅读小规则 *Sidebar: Magic Reading Rules* 本书采用中英双语排版,每段中文内容后都会附上对应的英文翻译,英文里的生词会加小注释(比如“Framework(框架:帮魔法师节省时间的工具包)”)。如果你英语特别好,可以试着先看英文部分,再对照中文核对哦!如果遇到不会的单词,别着急,翻到书最后的“魔法词汇表”就能找到详细解释啦。 *This book uses bilingual Chinese-English layout, with corresponding English translations after each paragraph of Chinese content, and new words in English will have small annotations (such as "Framework (framework: a tool kit that helps wizards save time)"). If you are good at English, you can try reading the English part first and then compare it with the Chinese! If you encounter words you don't know, don't worry, you can find detailed explanations in the "Magic Glossary" at the end of the book.* </div>
<div class="format-hint print-book">【纸书排版提示】此处插入卡通小插画:几个小魔法师挤在公告栏前抢信,其中一个举着信笑得露出缺了颗的门牙,旁边飘着两张银蓝色和金红色的贴纸。 【Digital Edition Interactive Tip】The cartoon illustration of the little wizards grabbing letters supports click interaction. Clicking on the letter will pop up the full content of the "Magic Tool Kit User Manual" with animated demonstration videos of the tool kit usage. </div>
你攥着刚领到的银蓝色小工具包,跟着PyTorch小法师走进魔法学院的入门教室,刚推开门就看见TensorFlow大法师坐在教室前面的高脚椅上,金红色的长袍拖在地上,像铺了一小片火烧云。大法师捋着白胡子笑着跟你们打招呼:“欢迎来到AI魔法学院呀小家伙们,你们手里的工具包,就是我们魔法师施展AI魔法的最强助手~很多人以为AI魔法是要魔法师自己从零开始变出来的,其实不是哦,我们的工具包早就把最麻烦的步骤都帮我们做完了。”
*You held the newly received silver-blue small tool kit and followed PyTorch the young wizard into the introductory classroom of the Magic Academy. As soon as you pushed the door open, you saw TensorFlow the archmage sitting on a stool in front of the classroom, his gold-red robe dragging on the ground like a small piece of fiery cloud. The archmage stroked his white beard and smiled at you: "Welcome to the AI Magic Academy, little guys. The tool kits in your hands are our strongest assistants for casting AI magic~ Many people think AI magic is something wizards conjure from scratch, but it's not. Our tool kits have already done all the most troublesome steps for us."*
要搞清楚工具包到底帮我们做了什么,我们得先知道AI魔法到底是怎么变出来的。你之前让平板给你画柯基的时候,是不是先告诉它“要画一只戴草莓贝雷帽的柯基”?这一步在魔法世界里叫“收集魔法素材”,也就是现实里的「数据收集(Data Collection)」:你得给AI小精灵看几千几万张戴贝雷帽的柯基、戴贝雷帽的狗、没戴贝雷帽的柯基的照片,告诉它哪些是你要的,哪些不是,就像你教刚会说话的小弟弟认猫一样,你得给他看好多好多猫的图片,告诉他“这是猫,毛茸茸的,有胡须,会喵喵叫”,他慢慢就记住了。
*To figure out exactly what the tool kit helps us with, we first need to know how AI magic is cast. When you asked the tablet to draw a corgi for you earlier, did you first tell it "I want a corgi wearing a strawberry beret"? This step is called "collecting magic materials" in the magic world, which is called "Data Collection" in real life: you have to show the AI elves thousands of pictures of corgis wearing berets, dogs wearing berets, and corgis not wearing berets, telling it which ones are what you want and which ones are not. It's like teaching your little brother who just learned to talk to recognize cats: you have to show him lots and lots of cat pictures, tell him "this is a cat, it's fluffy, has whiskers, and meows", and he will slowly remember it.*
收集完素材之后,魔法师就要画“魔法阵”了,也就是现实里的「搭建模型(Model Building)」:你得告诉AI小精灵,怎么判断一张图里的是不是戴贝雷帽的柯基——比如先看有没有毛茸茸的短腿,再看有没有圆滚滚的屁股,再看头上有没有贝雷帽,最后再看贝雷帽上有没有草莓图案。如果你不用工具包,就得自己一条一条把这些规则写出来,光写“怎么判断有没有毛茸茸的短腿”这一步,可能要写几千行的指令,特别麻烦。
*After collecting the materials, the wizard needs to draw the "magic array", which is called "Model Building" in real life: you have to tell the AI elves how to judge whether a picture is a corgi wearing a beret — for example, first look for fluffy short legs, then a round bottom, then a beret on the head, and finally check if there is a strawberry pattern on the beret. If you don't use a tool kit, you have to write these rules out one by one, and just the step of "how to judge whether there are fluffy short legs" may require writing thousands of lines of instructions, which is very troublesome.*
这时候魔法框架(也就是你手里的PyTorch或者TensorFlow工具包)就派上用场啦!工具包里已经提前帮你写好了几千几万行常用的指令:有帮你整理照片的魔法粉末(数据预处理工具),有已经画好一半的“识别动物”魔法阵模板(预训练模型),有能同时指挥几百个小精灵干活的魔法号角(运算调度工具)。你只要把收集到的柯基照片倒进工具包里,再稍微调整一下魔法阵的参数,剩下的工作工具包都会帮你自动完成。
*This is where the magic framework (the PyTorch or TensorFlow tool kit in your hand) comes in handy! The tool kit has already written thousands of common instructions for you in advance: there is magic powde