升级到 Babel 7 (API) · Babel 中文文档

Eclipse中文界面设置全攻略:从Babel语言包安装到乱码解决 在软件开发中,集成开发环境(IDE)的本地化是提升开发效率的重要环节。Eclipse作为一款广泛使用的开源IDE,其国际化支持通过插件机制实现,核心原理是语言资源包与运行时区域设置的匹配。这一机制的技术价值在于允许开发者在不修改核心代码的情况下,灵活切换界面语言,从而降低非英语母语开发者的学习曲线。在实际应用场景中,为Eclipse设置中文界面主要涉及官方Babel语言包的安装、版本匹配以及JVM参数配置。本文聚焦于通过Babel项目安装中文语言包的完整流程,并针对安装过程中常见的网络连接失败、界面汉化不全 阅读详情

Refer users to this document when upgrading to Babel 7.

Also check out the v7-migration guide for other user-level changes.
📖 去Js中文网 -前端进阶资源教程,上查看本手册体验更佳

All Babel packages

NodeJS support

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-raN83a6j-1574210640342)(https://static.javascriptc.com/imgs/tutorials/babels/babelhigh-rededf1d8b9.svg)]

Support for Node.js 0.10 and 0.12 has been dropped as both of this versions are out of maintenance.

Export changes

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-lN63qsX7-1574210640342)(https://static.javascriptc.com/imgs/tutorials/babels/babelm-yellow59598fa6.svg)]

Dropped use of add-module-exports plugin on Babel packages. This had to be used earlier to prevent a breaking change with our exports. If you import a Babel package in a library you may need to use .default when using require rather than import.

@babel/core

Changed ast to be false by default for performance (most tools aren’t using it) babel/babel#7436.

The publicly exposed but undocumented Pipeline class has been removed. Best to use the transformation methods exposed from @babel/core directly babel/babel#5376.

The babel.util.* helper methods have been removed, and util.EXTENSIONS has been moved to babel.DEFAULT_EXTENSIONS babel/babel#5487.

Calls to babel.transform or any other transform function may return null if the file matched an ignore pattern or failed to match an only pattern babel/babel#5487.

The opts.basename option exposed on state.file.opts has been removed. If you need it, best to build it from opts.filename yourself babel/babel#5467.

Removed resolveModuleSource. We recommend using babel-plugin-module-resolver@3's ‘resolvePath’ options babel/babel#6343

Removed babel.analyse because it was just an alias for babel.transform

Removed path.mark() since we didn’t use it and it can be implemented in your own plugin.

Removed babel.metadata since the generated plugin metadata is always included in the output result.

Removed path.hub.file.addImport. You can use the @babel/helper-module-imports module instead.

Js中文网 - 前端进阶资源教程 www.javascriptC.com ,Babel中文文档
一个致力于帮助开发者用代码改变世界为使命的平台

 diff
+  import { addDefault } from "@babel/helper-module-imports";
function importModule(pkgStore, name, path) {
-  return path.hub.file.addImport(resolvePath(pkgStore, name, path), 'default', name);
+  return addDefault(path, resolvePath(pkgStore, name, path), { nameHint: name });
}


Config changes

We’ve made some major changes to way config lookup works:

By default when searching for .babelrc files for a given file, stop at package.json.

For any particular file, Babel v6 keeps looking up the directory hierarchy until it finds a config file. This means your project might break because it uses a config file found outside the package root like in the home directory.

Adds support for a babel.config.js file along the lines of what Webpack does

Because this would break how a monorepo works (including Babel itself), we are introducing a new config file, that basically removes the hierarchical nature of configs.

Included is a root option that defaults to the current working directory for it to find the file. It is also not loaded relatively so it will handle symlinking correctly, whereas before you may have had hard-code the paths in webpack before.

Check the babel.config.js docs for more info: project-wide configuration

This file combined with the new overrides property and env lets you have a single config file that can work for all the files in a project vs. multiple config files per folder.

We also exclude node_modules by default and only look in the root unless you opt-in to setting an array of the .babelrcRoots option such as "babelrcRoots": [".", "node_modules/pkgA"]

Asserting Babel version #7450

Plugins can check that it’s loaded with a certain version of Babel. The API will expose an assertVersion method, where you can pass in semver.

The declare helper is used to keep backwards compat with v6.

Js中文网 - 前端进阶资源教程 www.javascriptC.com ,Babel中文文档
一个致力于帮助开发者用代码改变世界为使命的平台

 js
import { declare } from "@babel/helper-plugin-utils";

export default declare(api => {
  api.assertVersion(7);
  // ...
});


Babel plugins/presets

It currently takes it as the first parameter the babel object, and plugin/preset options, and the dirname

 js
module.exports = function(api, options, dirname) {};


babel-parser (known as Babylon)

Removed the * plugin option #301 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Hf5YCcH0-1574210640343)(https://static.javascriptc.com/imgs/tutorials/babels/babellowgreenf8d3b0d4.svg)]

This was first added in v6.14.1 (Nov 17, 2016) so it’s unlikely anyone was using this.

This catch-all option was removed; instead you should specifically decide which plugins you want to activate.

We thought it would be a good idea for tools so they wouldn’t have to constantly update their config but it also means we can’t easily make a breaking change.

Before:

 js
babelParser.parse(code, {
  plugins: ["*"],
});


You can get the old behavior using:

 js
babelParser.parse(code, {
  plugins: [
    "asyncGenerators",
    "classProperties",
    "decorators",
    "doExpressions",
    "dynamicImport",
    "exportExtensions",
    "flow",
    "functionBind",
    "functionSent",
    "jsx",
    "objectRestSpread",
  ],
});


Js中文网 - 前端进阶资源教程 www.javascriptC.com ,Babel中文文档
一个致力于帮助开发者用代码改变世界为使命的平台

See Babylon’s plugin options.

Renamed decorators plugin to decorators-legacy [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WO9ZwxII-1574210640343)(https://static.javascriptc.com/imgs/tutorials/babels/babelm-yellowf4f11149.svg)]

It has been renamed to align with the legacy option of @babel/plugin-proposal-decorators. A new decorators plugin has been implemented, which implements the new decorators proposal.

The two versions of the proposals have different syntaxes, so it is highly reccomended to use decorators-legacy until the new semantics are implemented by Babel.

Removed classConstructorCall plugin #291 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-N3dUJRwu-1574210640344)(https://static.javascriptc.com/imgs/tutorials/babels/babellowgreen3c29b784.svg)]

@babel/traverse

Remove support for flow bindings babel/babel#6528

The reason behind this change is that declare var foo doesn’t introduce a new local binding, but it represents a global one.

getFunctionParent will no longer return Program, please use getProgramParent instead #5923. [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-iTZf0PgU-1574210640344)(https://static.javascriptc.com/imgs/tutorials/babels/babellowgreenb634a625.svg)]

It doesn’t make sense that a function named getFunctionParent also returns the Program, so that was removed.

To get the equivalent behavior, you’ll need to make a change like

 diff
- path.scope.getFunctionParent()
+ path.scope.getFunctionParent() || path.scope.getProgramParent()


Path replacement/removal APIs now return an array of new paths [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VPWzo5RW-1574210640344)(https://static.javascriptc.com/imgs/tutorials/babels/babellowgreen25a05c73.svg)]

For instance, using Path#insertBefore, or Path#replaceWith will now always return an array of the newly inserted/replaced paths.

 js
const node = t.nullLiteral();
const [replaced] = path.replaceWith(node);
replace.node === node; // => true


This is especially useful when inserting serveral nodes into some higher-up scope, since you can immediately call the Path APIs on the node’s new Path.

 js
const parent = path.findParent(() => /* some selection criteria */);
const helperPaths = path.unshiftContainer("body", helpers);
// helperPaths can now be referenced, manipulated, etc.


AST changes

Add InterpreterDirective Node #7928

Babylon already parses “shebangs” (#!env node) but put’s in a comment in the Program node. Now we are just creating an actual node for it.

Add a new interpreter field to the Program node.

 js
extend interface Program {
  interpreter: InterpreterDirective;
}


Add the InterpreterDirective Node

 js
interface InterpreterDirective <: Node {
    type: "InterpreterDirective";
    value: string;
}


JSX* and TS* node builders (from @babel/types package) renamed

The case has been changed: jsx and ts are now in lowercase.

Js中文网 - 前端进阶资源教程 www.javascriptC.com ,Babel中文文档
一个致力于帮助开发者用代码改变世界为使命的平台

 diff
- t.jSXIdentifier()
+ t.jsxIdentifier()


In general, we have differentiated the node types with TypeAnnotation for Flow and TSTypeAnnotation for TypeScript so for the shared type nodes, TypeScript has a TS prefix.

.expression field removed from ArrowFunctionExpression

The expression field was removed to eliminate two different sources of truth and needing plugins to manually keep them in sync. You can now simply check whether the function body is a BlockStatement or not:

 diff
  return {
    visitor: {
      ArrowFunctionExpression({ node }) {
-       if (node.expression) {
+       if (node.body.type !== "BlockStatement") {
          // () => foo;
        }
      }
    }
  };


Tokens removed

In previous versions tokens were always attached to the AST on the top-level. In the latest version of @babel/parser we removed this behavior and made it disabled by default to improve the performance of the parser. All usages in babel itself have been removed and @babel/generator is not using the tokens anymore for pretty printing.

If your babel plugin uses tokens at the moment, evaluate if it is still necessary and try to remove the usage if possible. If your plugin really depends on getting tokens you can reactivate it but please only consider this if there is no other way as this will hurt users performance.

To activate you need to set the tokens option of babylon to true. You can do this directly from your plugin.

 js
export default function() {
  return {
    manipulateOptions(opts, parserOpts) {
      parserOpts.tokens = true;
    },
    ...
  };
}


Renamed

The following nodes have been renamed:

Name 6.x

Name 7.x

Example

PR

ExistentialTypeParam

ExistsTypeAnnotation

type A = B<*>;

#322

NumericLiteralTypeAnnotation

NumberLiteralTypeAnnotation

type T = 0;

#332

Besides the AST-Nodes also all the corresponding functions in @babel/types have been renamed.

 diff
 import * as t from "@babel/types";

 return {
-  ExistentialTypeParam(path) {
-    const parent = path.findParent((path) => path.isExistentialTypeParam());
-    t.isExistentialTypeParam(parent);
+  ExistsTypeAnnotation(path) {
+    const parent = path.findParent((path) => path.isExistsTypeAnnotation());
+    t.isExistsTypeAnnotation(parent);

-    return t.existentialTypeParam();
+    return t.existsTypeAnnotation();
   },
-  NumericLiteralTypeAnnotation(path) {
-    const parent = path.findParent((path) => path.isNumericLiteralTypeAnnotation());
-    t.isNumericLiteralTypeAnnotation(parent);
+  NumberLiteralTypeAnnotation(path) {
+    const parent = path.findParent((path) => path.isNumberLiteralTypeAnnotation());
+    t.isNumberLiteralTypeAnnotation(parent);

-    return t.numericLiteralTypeAnnotation();
+    return t.numberLiteralTypeAnnotation();
   }
 };


Replaced

On the following AST-Nodes the value of the field variance has been changed from a simple string value to be its own AST-Node called Variance. #333

The field is only available when enabling the flow plugin in babylon.

  • ObjectProperty
  • ObjectMethod
  • AssignmentProperty
  • ClassMethod
  • ClassProperty
  • Property

The type of the new Variance node looks like this:

 js
type VarianceNode = {
  type: "Variance",
  kind: "plus" | "minus",
};


 diff
 return {
   Property({ node }) {
-    if (node.variance === "plus") {
+    if (node.variance.kind === "plus") {
       ...
-    } else if (node.variance === "minus") {
+    } else if (node.variance.kind === "minus") {
       ...
     }
   }
 };


Location changes

The location info of ObjectTypeIndexer has been changed to not include semicolons. This was done to align with the flow-parser and have the same location information. #228

Example:

 js
var a: { [a: number]: string };


 diff
 {
   "type": "ObjectTypeIndexer",
   "start": 9,
-  "end": 29,
+  "end": 28,
   "loc": {
     "start": {
       "line": 1,
       "column": 9,
     },
     "end": {
       "line": 1,
-      "column": 29
+      "column": 28
     }
   }
 }


Removal
ForAwaitStatement

The AST-Node ForAwaitStatement has been removed and is replace with the field await in the ForOfStatement node #349

 diff
 interface ForOfStatement <: ForInStatement {
   type: "ForOfStatement";
+  await: boolean;
 }


 diff
 return {
-  ForAwaitStatement(path) {
-    ...
+  ForOfStatement(path) {
+    if (path.node.await) {
+      ...
+    }
   }
 };


RestProperty & SpreadProperty

The two AST-Nodes RestProperty and SpreadProperty have been removed in favor of reusing RestElement and SpreadElement #384

 diff
 return {
   SpreadElement(path) {
-    ...
-  },
-  SpreadProperty(path) {
-    ...
+    if (path.parentPath.isObjectExpression()) {
+      ...
+    } else if (path.parentPath.isArrayExpression()) {
+      ...
+    }
   },
   RestElement(path) {
-    ...
-  },
-  RestProperty(path) {
-    ...
+    if (path.parentPath.isObjectPattern()) {
+      ...
+    } else if (path.parentPath.isArrayPattern()) {
+      ...
+    }
   }
 };


See our upgrade PR for Babel and the Babylon AST spec for more information.

← 升级到 Babel 7编辑器 →

推荐阅读:

领略前端前沿,关注IT平头哥联盟,做有温度的攻城狮!,公众号:honeyBadger8

来源:Js中文网 - 前端进阶资源教程
链接:https://www.javascriptc.com/docs/babel-manual/v7-migration-api

Babel 7 升级指南:从旧版本平滑迁移 本文面向所有使用 Babel 6 及以下版本的前端开发者,覆盖 React、Vue、Node.js 等主流场景,重点解决升级过程中依赖冲突、配置失效、插件兼容性三大核心问题,帮助团队快速完成工具链迭代。本文将按照“认知变化→动手迁移→验证优化”的逻辑展开,先解析 Babel 7 的核心差异,再通过实战步骤演示迁移过程,最后总结常见问题和未来趋势。原因版本过低,或未安装。解决确保版本 ≥7.0.0;检查中是否包含(不是Babel 是 JavaScript 转译工具,通过“解析→转译→生成”三阶段工作; 阅读详情

相关推荐

Jaspersoft Studio 6.21.3实用指南:安装、汉化与中文字体配置

报表开发是Java企业应用中常见的数据呈现方式,通过可视化设计器将数据库、JSON或XML数据源映射为PDF、Excel等格式文档,能大幅提升开发效率。其核心原理是基于JRXML模板引擎,将字段绑定、参数传递与布局设计分离,实现数据与视图解耦。熟练掌握设计器工具,不仅便于快速构建高质量报表,还能高效维护历史项目。在实际工程中,报表常面临环境配置、中文乱码、数据源连接等痛点,尤其当涉及多平台部署或PDF导出时,中文字体与JDK版本兼容性成为关键瓶颈。Jaspersoft Studio 6.21.3作为6.x时

weixin_28837817的博客 244

升级到 Babel 7 · Babel 中文文档

Refer users to this document when upgrading to Babel 7.Because not every breaking change will affect every project, we've sorted the sections by the likelihood of a change breaking tests when upgrading.

Js中文网 - www.javascriptc.com 2781

NFS共享速度慢?麒麟系统性能调优5个关键参数实测对比

本文针对银河麒麟服务器系统上NFS共享速度慢的问题,通过实测对比分析了五个关键调优参数。重点探讨了rsize/wsize传输块大小、TCP/UDP协议选择、sync/async模式权衡等,并结合麒麟系统特性提供了具体的优化建议与配置示例,旨在帮助用户有效提升国产化环境下的文件共享性能。

weixin_29254029的博客 338

webpack5学习笔记

webpack5学习笔记 cdn资源 cdn资源 webpack官网 webpack插件 webpack笔记 解决作用域问题 快速执行函数 ;(function(){ … }) 解决代码拆分问题 node commonjs 模块化 解决浏览器支持问题 requirejs 想要主js调用别的js要在主js前引入 hello.js export hello() main.js hello() import hello.js import main.js 安装webpack 先安装node 然后安装webpack

代码哈士奇的博客 1455

【无标题】STM32F767串口空闲中断+DMA实现不定帧长度的接收

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录前言一、配置串口与DMA二、空闲中断服务函数二.串口+DMA发送三、主函数总结 前言 提示:这里可以添加本文要记录的大概内容: 使用STM32F767实现串口空闲中断+DMA传输接收不定帧长度数据,以及当中可能遇到的错误总结 提示:以下是本篇文章正文内容,下面案例可供参考 一、配置串口与DMA //硬件模块配置可直接通过CUBEMX配置 void MX_USART1_UART_Init(void) { huart1.In.

qq_42589531的博客 1168

LaTeX新手入门以及TeXlive和TeXstudio的安装使用

作为一个新手,LaTeX的了解和使用很是费了一番功夫,因此,在这里给找不到路的同志们稍微介绍一下。如有错误,敬请指正。本篇内容基于Win10系统,因此安装在Mac或者Linux上的同学可以再找找其他的介绍文章。 目录 LaTeX介绍 LaTeX环境配置 一、TeXlive下载 二、TeXlive安装 1. 安装main installer 2. 正式安装 三、TeXstudio安装...

zywhehe的博客 21万+

vue 打包异常记录

Module build failed (from ./node_modules/_vue-loader@13.3.0@vue-loader/index.js): TypeError: Cannot read properties of undefined (reading 'vue') package.json 或者.babelrc 中添加 "presets":[ "@vue/app"] Error: Multiple configuration files found. Please remov.

u014685642的博客 1万+

2026软考中级-软件设计师笔记(送最新视频教程)

核心口诀:运控存输输(运算器、控制器、存储器、输入、输出)例题(2019年上半年):核心公式:数字签名流程:数字证书作用:死锁4个必要条件:死锁判断公式:处理策略:程序设计语言的四大核心成分:顺序表操作(时间复杂度):链表操作(时间复杂度):核心思想:频率高的字符用短编码,频率低的用长编码 → 最小化总编码长度构造步骤(贪心算法):前提:有序表(升序/降序) 步骤:时间复杂度:O(log₂n) 例:查找中核心思想:用哈希函数将关键字映射到存储位置 哈希冲突:不同关键字映射到同一位置 → 用链地址法或开放定址

36万+

关于安装babel时出现的错误以及解决办法

在开始接触到react之初,安装babel插件是一件必须要做的事情,但是我在安装的时候,出现了一个错误,这个错误刚开始很头疼,在网上找了各种解决的办法,但是一直不行,直到今天,也就是解决安装错误的第三天,临近崩溃的我,安装成功了,首先来看下错误。 ERROR in ./src/index.js Module build failed (from ./node_modules/_babel-load...

zhuhui2000的博客 4336

基于A*算法的二维栅格地图路径规划与避障MATLAB仿真

本文将介绍如何使用MATLAB编写基于A*算法的二维栅格地图路径规划与避障的仿真程序。我们可以使用二维数组表示地图,其中每个元素表示一个栅格的状态,例如1表示障碍物,0表示可行走区域。接下来,我们需要定义A*算法的节点类。G值表示从起始节点到当前节点的代价,H值是启发式函数估计的从当前节点到目标节点的代价。算法,我们可以有效地找到起始点到目标点的最短路径,并在仿真中进行可视化展示。算法的基本思路是从起始节点开始,按照一定的启发式函数选择下一个节点,直到找到目标节点或者遍历完所有可行走区域。

ByteWhizX的博客 1275

基于matlab的LFM脉冲压缩仿真

传统雷达测距是通过发射点频脉冲串实现的,通过发射脉冲与回波的时延确定目标的距离。此类方法易于实现,对接收机的要求较低。一般要获取更好的距离分辨力,需要增加发射信号的带宽,对于点频脉冲信号即需要减小发射脉冲宽度;而为获取更大的探测距离,提升雷达威力,则需要发射更大占空比的脉冲串。由于点频信号的时宽带宽积约等于1,因此不能同时增加信号的时宽和带宽。若要保持距离分辨力,增大占空比就需要减少雷达的脉冲重复周期(PRT)。这样会减小雷达的无模糊探测距离,也会造成目标回波频繁被遮挡,损失雷达威力。

平时工作较为繁忙,私信消息一般晚上回复,谢谢大家~~ 1771

Cannot find module @babel/helper-module-imports

vue 项目中引入 element-ui 时报错 我的报错场景,当复制项目到另一台电脑启动时报错 报错信息 Cannot find module '@babel/helper-module-imports' 解决办法 cnpm install --save-dev @babel/helper-module-imports

笑望灬星辰 5174

网红商品数据抓取:基于Python的高效爬虫实战

本篇博客介绍了从爬取到存储、分析和可视化网红商品数据的完整流程。通过Python的强大生态,我们能够轻松完成复杂的数据抓取任务。在实际应用中,还可以将此爬虫与机器学习模型结合,进一步挖掘数据价值。

2201_76125261的博客 1478

Babel入门·Babel 中文文档

Babel 是一个 JavaScript 编译器。Babel 是一个工具链,主要用于将 ECMAScript 2015+ 版本的代码转换为向后兼容的 JavaScript 语法,以便能够运行在当前和旧版本的浏览器或其他环境中。下面列出的是 Babel 能为你做的事情:语法转换,通过 Polyfill 方式在目标环境中添加缺失的特性 (通过 @babel/polyfill 模块),源码转换 (codemods,Js中文网 www.javascriptc.com)

Js中文网 - www.javascriptc.com 2079

glibc: GLIBC_2.28‘ not found

这个时候,应该怎么解决,因为当前运行的机器是低版本,而程序是高版本,解决方法,或者是将程序降级,或者将当前系统升级。在一个glibc的接口版本是GLIBC_2.25的lab上,运行不了在2.28上编译的程序。看哪一个方便,但是不能通过 临时复制libc.so 文件来解决,因为会遇到下面的错误。所以如果是简单解决就是按照低版本的应用程序,来适配当前系统的glibc版本。比如下面的程序运行提示。

mzhan017的博客 2408

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

vue cli 3 升级到 vue cli 4 方法步骤及升级点总结

vue cli 3 升级到 vue cli 4 指南 vue cli 3 升级到 vue cli 4 方法步骤及升级点总结 vue-cli 3升级vue-cli 4 官方英文升级文档,中文滞后 一.首先,在全局安装最新的 Vue CLI: npm install -g @vue/cli # OR yarn global add @vue/cli 检查安装的版本 vue -V # 输出:@vue/cli 4.x.x 说明@vue/cli 4安装成功( vue cli 3的版本会输出 3.x.x )

前端开发者 8万+

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

ArchiveXL 体型扩展(Body Types)完全指南:为 Mod 服装添加专属体型

ArchiveXL 是一款面向《赛博朋克 2077》的 Mod 资源扩展工具,它的 Body Types(体型)功能允许你为 Mod 服装添加**按角色体型区分的专属外观**——玩家无论使用默认体型还是自定义体型 Mod 的改造身体,穿上你的衣服都能获得贴合身形的专属效果,且不同 Mod 之间互不冲突。本文是面向新手和普通用户的完整指南,带你从零理解工作原理,再到一步步完成配置。 ## 为什么需

gitblog_00383的博客 471

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Node.js API兼容性问题解析与解决方案

Node.js作为流行的JavaScript运行时,其API兼容性问题是开发者在版本升级时常遇到的挑战。API兼容性涉及废弃API、实验性功能和稳定API三类,其中废弃API如Domain模块和Punycode模块在迁移时尤为棘手。理解Node.js的Stability Index文档是评估API可靠性的关键。在实际应用中,兼容性问题可能导致项目卡在旧版本,影响性能和安全。通过版本锁定策略、渐进式迁移方案和兼容性测试套件,开发者可以有效应对这些问题。本文特别关注Node.js v12到v20的API变化,为

weixin_34082854的博客 545

为什么Immich国家名不能显示中文?深入i18n-iso-countries机制与immich-geodata-cn的解法

在 Immich 里给照片开启反向地理编码后,很多人都会遇到同一个问题:明明拍的是上海、天津,地图上却显示 `People's Republic of China`。这是 **Immich 中文反向地理编码** 场景下的经典痛点,而开源项目 **immich-geodata-cn** 正是为此而生——它把照片地点完整汉化成"国家、省、市"三级中文地名,还支持用中文地名搜索照片。本文会讲清楚"国家名

gitblog_00345的博客 986

Qwen3.7-Max:生产级智能体的三层自治能力解析

智能体(Agent)是大模型从‘回答问题’迈向‘执行任务’的关键范式,其核心在于任务闭环能力——即自主规划、工具调用与异常恢复的有机统一。Qwen3.7-Max并非简单升级参数规模,而是通过原生化工具嵌入、动态MCP决策树与跨框架语义同构三大技术突破,实现从单次响应到多步自治的本质跃迁。它在Terminal Bench2.0-Terminus和SWE-Pro等真实终端与软件工程场景中验证了高鲁棒性与低错误率,显著优于传统插件式Agent架构。本文聚焦其底层行为逻辑,揭示其如何将Linux命令、API调用、代

HJ921004的博客 565

GLM-4.7 前端实战指南:为什么它是生产级代码助手首选

大语言模型在前端开发中的落地,核心不在参数规模或上下文长度,而在于响应稳定性、结构可控性与工作流契合度。GLM-4.7 作为专注‘高质量助手’定位的模型,通过强化前端语料微调(如 GitHub Issues、Vue/React 官方文档评论)、严格约束输出格式(如仅返回 .tsx 文件、禁用未声明依赖),显著降低幻觉率与协作成本。其128K上下文与32K输出限制反而带来更可预测的 token 行为,适配 VS Code 插件、Vite 构建链、组件文档自动生成等典型前端场景。相比强调多跳推理的 GLM-5,

weixin_30367873的博客 365

模板驱动型文档自动化:零代码实现多格式专业文档批量生成

文档自动化是企业内容运营提效的核心路径,其本质是将重复性排版与结构化输出任务从人工操作中解耦。基于模板驱动的自动化方案,依托可复用的原子组件、条件逻辑引擎和样式继承体系,实现PDF/DOCX/HTML等多格式一键生成,兼顾品牌一致性与业务合规性。相比AI全文生成,模板方案在可控性、结构处理能力及系统集成性上更具工程落地优势,尤其适用于销售提案、客户案例、合规报告等高频标准化文档场景。本文深入解析模板语法设计、动态区块编排与三级分层架构,揭示如何让模板真正成为承载业务规则的数字执行体。

weixin_33938733的博客 374

Node.js语法错误排查:Unexpected token ... 的根源与解决方案

在JavaScript开发中,语法错误是常见的调试难点,尤其是当代码在解析阶段就遇到无法识别的标记时。这类错误通常源于运行环境的JavaScript引擎版本与代码中使用的ECMAScript语法特性不匹配。ECMAScript标准每年都会引入新的语法特性,例如ES2015(ES6)中引入的展开运算符(Spread Operator)和剩余参数(Rest Parameters),它们在现代前端工程化和Node.js服务端开发中广泛应用。如果运行环境的Node.js版本过低,其捆绑的V8引擎可能无法解析这些新语

chuange6363的博客 499

Docusaurus 文档站点开发实战指南:配置、侧边栏、版本化与国际化(以 Farm 官方文档为例)

本篇技术指南围绕 Docusaurus 文档站点开发的全流程展开,覆盖项目初始化、核心配置解析、侧边栏组织、自定义 MDX 组件、多版本文档、国际化(i18n)、自定义插件与 Algolia DocSearch 搜索集成。文中以 Rust 编写的开源构建工具 Farm 仓库中的官方文档站点([website](https://link.gitcode.com/i/bccb6f51ce3a81367

gitblog_00596的博客 183

iperf3 测速报错怎么排查:新手常见的 5 类问题一次性讲清

iperf3 是一款 TCP/UDP/SCTP 网络带宽测量工具,但实际使用时经常会碰到连不上、测速不准等报错。本文按「先自查、再对症状、后进阶」的顺序,带你逐步定位 iperf3 网络测速报错的原因,并给出可直接运行的最小命令。 [![iperf3 网络测速工具标识](https://raw.gitcode.com/gh_mirrors/ip/iperf/raw/a004933607da4bc

gitblog_00054的博客 78

STM32CubeIDE安装汉化与深色主题配置指南

嵌入式开发中,IDE 是把编辑器、交叉编译器、调试器与芯片配置工具串联起来的一体化入口。STM32CubeIDE 以 Eclipse 为底座,集成 GCC/GDB、STM32CubeMX 图形化配置与 ST-LINK 调试链路,让 STM32 工程从引脚配置、编译到下载调试在同一环境完成,适合学生、转行工程师和跨平台团队快速搭建开发环境。实际落地时,安装路径、工作空间、语言包版本与编辑器配色往往决定效率,错拼 STM32CudeIDE 也能搜到同类需求。围绕 STM32CubeIDE 安装、汉化和深色主题调

weixin_34209851的博客 297
上一篇: 升级到 Babel 7 · Babel 中文文档
下一篇: 编辑器 · Babel 中文文档
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值