参数引发的复制中断:max_binlog_cache_size 导致 SQL 线程异常的复现与分析

MySQL一些参数设置不当引发的血案 文章目录slave_rows_search_algorithmsmax_binlog_cache_size问题描述场景复现参数解释 slave_rows_search_algorithms slave_rows_search_algorithms 参数主要由 index_scan 、 table_scan 、 hash_scan 组成,他们决定了行模式复制下,slave如何对binlog日志以及数据库记录进行扫描匹配。 index_scan : 当表存在索引(主键索引、唯一索引、普通二级索引)时,尽可能通 阅读详情

问题发生

某个客户的一套数据库,主库为 MySQL 5.7.44,从库为 GreatSQL 8.0.32-27,从库的 SQL 线程中断,报错如下:

2026-05-07T21:53:42.151856+08:00 145 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 1 failed executing transaction '18c68804-62e7-11f1-846e-00163ed55da5:3425315180' at master log binlog.022823, end_log_pos 127908803; Could not execute Write_rows event on table ort.bm_cdr; Writing one row to the row-based binary log failed, Error_code: 1534; handler error HA_ERR_RBR_LOGGING_FAILED; the event's master log FIRST, end_log_pos 627908803, Error_code: MY-001534
2026-05-07T21:53:42.245982+08:00 144 [Warning] [MY-010584] [Repl] Slave SQL for channel '': ... The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state. A restart should restore consistency automatically, although using non-transactional storage for data or info tables or DDL queries could lead to problems. In such cases you have to examine your data (see documentation for details). Error_code: MY-001756

报错信息表示:主库在回放事务 18c68804-62e7-11f1-846e-00163ed55da5:3425315180 时失败了,失败位置发生在执行 Write_rows 事件写入从库本地 row-based binlog 的过程中,最终导致 SQL 线程终止。

问题排查

看到 Could not execute Write_rows event on table,容易误以为是表数据写入失败或数据冲突。

  • Writing one row to the row-based binary log failed
  • Error_code: 1534
  • handler error HA_ERR_RBR_LOGGING_FAILED

这说明故障与从库写本地 binlog 有关。该从库开启了本地 binlog,并记录复制回放产生的更新,即开启了 log_slave_updates / log_replica_updates。因此,SQL 线程不仅要把主库事务回放到表中,还要把该事务再次写入从库自己的 binlog;如果从库 binlog 事务缓存上限过小,就可能在回放大事务时失败。

对比主库和从库参数后,发现关键差异如下:

主库 max_binlog_cache_size = 4G
从库 max_binlog_cache_size = 10M

主库允许生成较大的事务 binlog,而从库写本地 binlog 时只允许最多使用 10M 的事务缓存。将从库 max_binlog_cache_size 调整为与主库一致后,再启动 SQL 线程,复制恢复正常。

随后使用 mysqlbinlog 解析故障 GTID 对应的 binlog,并与业务侧确认,该 GTID 确实是一个大事务,事务产生的 binlog 体量远超从库 10M 的 max_binlog_cache_size 限制。

我们知道,通常当max_binlog_cache_size设置过小时,会有 Error_code: MY-001197 的报错,那什么时候会出现仅有 Error_code: MY-001534 的报错呢?本文整理复现过程如下。

实验验证

测试环境参数配置

搭建主从异步复制环境,主库端参数配置如下:

binlog_cache_size                              =32768
max_binlog_cache_size                          =4294967296  #4G
max_binlog_size                                =1073741824
binlog_row_image                               =FULL
binlog_rows_query_log_events                   =ON

从库端参数配置如下:

binlog_cache_size                              =32768
max_binlog_cache_size                          =10485760   #10M
max_binlog_size                                =1073741824
binlog_row_image                               =FULL
binlog_rows_query_log_events                   =ON
log_replica_updates                            =ON

复现该问题的关键前提是:从库开启本地 binlog,并记录复制回放的更新。如果从库不写本地 binlog,通常不会在 SQL 线程回放时触发本地 max_binlog_cache_size 限制。

创建测试表

在主库创建测试表并插入数据

mysql> CREATE TABLE test.t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c2 VARCHAR(255), c3 VARCHAR(255), c4 VARCHAR(255), c5 VARCHAR(255));
mysql> INSERT INTO test.t1 VALUES (NULL, REPEAT('a', 250), REPEAT('b', 250), REPEAT('c',250), REPEAT('d', 250));
-- 持续执行如下语句14次
mysql> INSERT INTO test.t1 (c2,c3,c4,c5) SELECT c2,c3,c4,c5 FROM t1;
mysql> SELECT COUNT(*) FROM test.t1;
+----------+
| count(*) |
+----------+
|    16384 |
+----------+
1 row in set (0.04 sec)

实验一:单语句大事务触发错误 1197 + 1534

主库执行如下INSERT语句,插入10319条数据,这时产生的 binlog 未超过从库max_binlog_cache_size=10M的限制,查看主从复制状态没有异常,且主从数据一致。

mysql> INSERT INTO test.t1 (c2,c3,c4,c5) SELECT c2,c3,c4,c5 FROM t1 LIMIT 10319;
Query OK, 10319 rows affected (0.62 sec)
Records: 10319  Duplicates: 0  Warnings: 0

主库执行如下INSERT语句,插入10320条数据,这时产生的binlog已经超过从库max_binlog_cache_size=10M的限制。

mysql> INSERT INTO  test.t1 (c2,c3,c4,c5) SELECT c2,c3,c4,c5 FROM t1 LIMIT 10320;
Query OK, 10320 rows affected (0.62 sec)
Records: 10320  Duplicates: 0  Warnings: 0

再次查看主从复制状态,SQL 线程已经异常终止,error.log 中打印错误信息如下:

2026-06-10T11:19:02.366583+08:00 212 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 1 failed executing transaction '18c68804-62e7-11f1-846e-00163ed55da5:85' at master log binlog.000001, end_log_pos 755113733; Could not execute Write_rows event on table test.t1; Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage; increase this mysqld variable and try again, Error_code: 1197; Writing one row to the row-based binary log failed, Error_code: 1534; handler error HA_ERR_RBR_LOGGING_FAILED; the event's master log binlog.000001, end_log_pos 755113733, Error_code: MY-001197
2026-06-10T11:19:02.548790+08:00 211 [Warning] [MY-010584] [Repl] Slave SQL for channel '': ... The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state. A restart should restore consistency automatically, although using non-transactional storage for data or info tables or DDL queries could lead to problems. In such cases you have to examine your data (see documentation for details). Error_code: MY-001756

可以看到错误日志中明确提示max_binlog_cache_size过小,错误码为1197+1534。此时调大max_binlog_cache_size再 START SLAVE 问题即可解决。

实验二:多语句事务只暴露错误 1534

在主库开启事务,依次执行以下语句:

mysql> BEGIN;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO  test.t1 (c2,c3,c4,c5) SELECT c2,c3,c4,c5 FROM t1 LIMIT 10319;
Query OK, 10319 rows affected (0.25 sec)
Records: 10319  Duplicates: 0  Warnings: 0

mysql> INSERT INTO  test.t1 VALUES (NULL, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
Query OK, 1 row affected (0.00 sec)

mysql> COMMIT;
Query OK, 0 rows affected (0.06 sec)

此时观察从库主从复制状态,显示 SQL 线程状态异常,error.log 中信息如下,可以看到,只有1534报错码,没有提示max_binlog_cache_size过小的信息。

2026-06-10T11:34:24.333342+08:00 232 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 1 failed executing transaction '18c68804-62e7-11f1-846e-00163ed55da5:86' at master log binlog.000001, end_log_pos 771775512; Could not execute Write_rows event on table test.t1; Writing one row to the row-based binary log failed, Error_code: 1534; handler error HA_ERR_RBR_LOGGING_FAILED; the event's master log FIRST, end_log_pos 771775512, Error_code: MY-001534
2026-06-10T11:34:24.537353+08:00 231 [Warning] [MY-010584] [Repl] Slave SQL for channel '': ... The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state. A restart should restore consistency automatically, although using non-transactional storage for data or info tables or DDL queries could lead to problems. In such cases you have to examine your data (see documentation for details). Error_code: MY-001756

实验结论

以上两种情况,都是由于从库端max_binlog_cache_size设置过小导致SQL线程异常终止。前者是批量插入,binlog Event 总量超过 max_binlog_cache_size 限制时,数据库会抛出明确的 1197 错误(缓存超限),并伴随 1534 错误(单行写入失败)。

后者是最后一个单行插入语句生成的 Row Event 过大,超出了当前 binlog Cache 剩余可用空间,导致这一行无法写入,从而仅触发 1534 错误。虽然 error.log 记录的信息不同,但都属于同一故障。

总结

  1. 从库也会受 binlog cache 限制。 只要从库开启本地 binlog 并记录复制更新,SQL 线程回放事务时就要写本地 binlog,因此会受从库 max_binlog_cache_size 限制。
  2. 1534** 不是数据冲突。** 当日志中出现 Writing one row to the row-based binary log failed 和 HA_ERR_RBR_LOGGING_FAILED 时,应优先检查 row-based binlog 写入链路,包括 max_binlog_cache_size、磁盘空间、临时目录、本地 binlog 配置等。
  3. 主库和从库关键参数应保持基线一致。 尤其是 max_binlog_cache_size、binlog_format、binlog_row_image、max_allowed_packet、lower_case_table_names 等会影响复制兼容性或回放行为的参数,建议在变更前后做自动化比对。
  4. 大事务是根因风险。 调大 max_binlog_cache_size 可以恢复复制,但不能消除大事务带来的 binlog 膨胀、复制延迟、回滚成本、备份恢复耗时等问题。批量 DML 应尽量拆分成小事务分批提交。
  5. 不要混淆 max_binlog_cache_size 和 max_binlog_size。 前者限制单事务写 binlog 可使用的缓存上限,后者只是 binlog 文件滚动的期望大小。一个大事务不会被拆到多个 binlog 文件中。
  6. 阈值不要照搬。 本文中 10319/10320 行只是当前表结构、字符集、row image、binlog 配置和版本组合下的临界点。换成其他表结构或参数后,临界点会变化。
Lakehouse架构实战:云原生实时数仓与SQL化治理落地指南 Lakehouse作为融合数据湖弹性与数仓管理能力的新一代架构,其核心在于通过Delta Lake/Iceberg等开放表格式实现ACID事务、Schema演化与时间旅行,结合Flink/Trino/Spark等引擎协同完成批流一体计算。技术价值体现在显著降低数据错乱率、支持声明式SQL建模及自动血缘追踪,广泛应用于实时风控、电商GMV分析、用户行为洞察等高时效性场景。本文聚焦Lakehouse在云原生环境下的真实落地路径,涵盖S3存储优化、Flink实时建模、dbt SQL化治理、Delta元数据协同等关 阅读详情

相关推荐

Canal数据库增量日志解析:从原理到生产环境部署与调优

在数据驱动的现代架构中,数据库变更数据捕获(CDC)是实现实时数据同步、缓存更新和搜索索引构建的核心技术。其原理是通过解析数据库的二进制日志(binlog),将数据变更事件转化为可被下游系统消费的消息流。这项技术的核心价值在于实现了业务逻辑与数据同步的解耦,无需侵入业务代码即可实现低延迟、高一致性的数据流动。在实时数仓、微服务数据分发等应用场景中,CDC技术至关重要。本文聚焦于阿里巴巴开源的Canal,它通过模拟MySQL从库协议实时拉取并解析binlog,扮演了数据库变更事件的“翻译官”和“搬运工”角色。

weixin_30920513的博客 394

mysql 1197_1197多行事务要求更大的max_binlog_cache_size处理与优化

1 mysql> set @@global.max_binlog_cache_size=500000000;2 Query OK, 0 rows affected, 1 warning (0.00sec)34 mysql>show slave status \G;5 *************************** 1. row *************************...

weixin_42535720的博客 453

DeepSeek国产大模型工程实践:知识库构建与摩尔线程适配指南

大模型知识库系统是企业AI落地的核心基础设施,其本质是将非结构化知识转化为可检索、可验证、可演进的机器可执行规则。实现高可用需兼顾语义理解精度、长上下文稳定性与国产硬件适配能力。DeepSeek通过三阶语义切片、动态水印追溯、MoE稀疏调度等工程创新,在中文政策合规、金融风控等强规则场景中显著提升信息抽取准确率与推理确定性。结合摩尔线程MTT S4000显卡深度优化,达成FP16下92% A100吞吐效率,为信创环境提供从模型训练、推理部署到知识治理的全栈可控方案。

weixin_30666401的博客 351

mysql无论输入什么语句都报错_mysql报错

1、无论在mysql中执行什么语句,都会报以下错误:You must reset your password using ALTER USER statement before executing this statement.在网上找了一下原因,看到以下信息这就是因为数据库的这个默认的default_password_lifetime参数导致的在数据库中执行select version(),显示...

weixin_39531761的博客 882

MySQL性能优化实战:从硬件配置、索引设计到架构演进全解析

数据库性能优化是后端开发与系统架构中的核心课题,其本质在于通过系统性的方法减少数据存取延迟、提升吞吐量。其原理涉及存储引擎的工作机制、索引数据结构(如B+树)以及查询执行计划等底层知识。掌握这些技术对于构建高并发、低延迟的应用具有重要价值,能直接提升用户体验和系统稳定性。在应用场景上,无论是应对用户量激增导致的查询变慢,还是处理海量数据下的存储瓶颈,都需要一套从底层硬件、SQL语句到系统架构的完整优化体系。本文聚焦MySQL这一主流关系型数据库,深入探讨如何通过配置调优、索引设计、查询重构及读写分离、分库分

weixin_30824599的博客 551

c#笔记之mes上传Http协议版

HTTP(超文本传输协议) 是一种典型的协议。

qq_61441787的博客 343

MySQL Binlogging Fails With “Writing One Row To The Row-based Binary Log Failed“ (Doc ID 2364888.1)

APPLIES TO: MySQL Server - Version 5.6 and later Information in this document applies to any platform. GOAL Explain why binlog can't be written and error reported is: ERROR 1534 (HY000): Writing one row to the row-based binary log failed SOLUTION max_

你好我是李白 2357

1.STM32H743VGT6最小系统板

此款MCU具备较大算力进行频谱运算,为复杂数据运算提供更高效的保障。该MCU具备REV-V和REV-Y两个型号,后者为新版本。

Audiation88的博客 3795

max_binlog_cache_size 导致 SQL 线程异常的复现与分析

随后使用 mysqlbinlog 解析故障 GTID 对应的 binlog,并与业务侧确认,该 GTID 确实是一个大事务,事务产生的 binlog 体量远超从库 10M 的 max_binlog_cache_size 限制。本文整理复现过程如下。主库执行如下INSERT语句,插入10319条数据,这时产生的 binlog 未超过从库max_binlog_cache_size=10M的限制,查看主从复制状态没有异常,且主从数据一致。从库 max_binlog_cache_size = 10M。

gjzNKt9z7的博客 189

python 爬虫 xpath 存储到数据库

参考

我是张先生 1289

AD22等长布线规则

本文介绍了PCB布线中实现信号线等长的详细操作步骤:1.创建网络类(NetClass),将需要等长的信号线归入同一组;2.设置高速布线规则(High-SpeedRule),定义等长容差等参数;3.进行交互式等长布线(InteractiveLengthTuning),使用蛇形线调整线长;4.实时调整与最终检查,确保所有网络满足等长要求。文中还提供了实用技巧,如使用快捷键调整蛇形线参数、为关键信号设置更严格规则等。操作需在PCB设计软件中完成,通过统一管理、规则设置和精确调整来实现信号同步传输。

whm128的博客 1557

一则 MySQL 参数设置不当导致复制中断的故障案例

在日常的运维工作中,偶尔会遇到一些意想不到的线上问题,多数因为设置不当导致故障。前段时间,DMP 数据库运维平台报错主从复制 SQL 线程断开,就是因为一个参数设置异常导致的。本文分享一下当时的情况。在运维过程中,合理配置和及时调整参数是确保系统稳定性和性能优化的重要环节,在修改一些参数的时候要充分了解相关知识概念,并且要掌握复制集群中相同参数的配置情况,确保合理合规修改,减少生产故障。

ActionTech的博客 778

SAP S/4HANA Cloud 管理员业务角色创建实战:基于 SAP_BR_ADMINISTRATOR 模板的一站式指南

摘要:SAP S/4HANA Cloud新系统初始登录时常见Fiori Launchpad无磁贴的问题,这是由于缺乏合适的业务角色分配。本文介绍了通过预交付的SAP_BR_ADMINISTRATOR模板创建管理员角色的完整流程,包括业务用户、业务角色和业务目录的核心概念解析。重点说明了直接使用模板的风险,并提供了从模板创建自定义管理员角色的详细步骤(4.1-4.3),以及权限限制设置的注意事项。文中还分享了一个实际项目案例,强调正确配置管理员角色对后续权限体系建设的关键作用。(149字)

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 204

MySQL Binlog深度解析:从数据恢复到主从复制与实时数据流处理

在数据库管理与数据架构领域,日志系统是保障数据一致性与可靠性的核心技术基础。其核心原理在于记录数据库的所有变更操作,形成可追溯的事件序列,为数据恢复和同步提供底层支持。这一机制的技术价值不仅体现在灾难恢复时的数据回滚能力,更是构建高可用架构、实现实时数据分发的基石。在应用场景上,它支撑着数据库主从复制、跨系统数据同步、实时分析管道等关键业务。本文聚焦MySQL的二进制日志(Binlog),深入探讨其作为**数据恢复**与**主从复制**核心引擎的实现细节,涵盖ROW/STATEMENT/MIXED三种格式的

weixin_30387799的博客 359

Open3D 点云重叠区域检测【2025最新版】

本文介绍了一种基于八叉树和KD树的点云重叠区域检测方法。算法提供两种检测模式:八叉树(快速)和KD树(精确),支持可视化显示和详细统计信息输出。实现功能包括边界扩展、索引去重、精度调节等,可通过max_depth参数控制八叉树细分程度,distance_threshold调整检测精度。代码使用Open3D库,能自动计算并显示各点云的重叠比例和点数统计,最终结果以不同颜色区分重叠与非重叠区域。该方案适用于三维点云数据处理中的重叠分析任务。

点云侠的博客 599

基于 MATLAB 的 FastICA 算法实现语音信号盲分离

FastICA 算法通过最大化信号的非高斯性,找到独立成分,从而实现信号的分离。这些混合的信号被称为盲源信号,我们希望通过分析混合信号,将它们分离出来以便进行进一步的处理和分析。FastICA 是一种常用的盲源信号分离算法,它基于统计学原理,通过寻找独立成分来实现信号的分离。FastICA(独立成分分析)是一种常用的盲源信号分离算法,在语音和图像处理领域都有广泛的应用。本文将介绍如何使用 MATLAB 实现 FastICA 算法来实现语音信号的盲分离,并提供相应的源代码。FastICA 算法原理。

学习使你进步。 2024

MySQL binlog 核心原理、实战应用与生产环境优化指南

数据库日志是记录数据变更的核心机制,它确保了数据操作的持久性与可追溯性。其底层原理是通过记录对数据库结构和内容的修改事件,为数据复制、恢复及审计提供基础。这一技术对于保障数据一致性、实现高可用架构具有关键价值,广泛应用于主从同步、实时数据分析、数据审计和故障排查等场景。其中,MySQL 的 binlog(二进制日志)作为实现数据复制(Replication)和实时数据流处理(CDC)的关键组件,其三种格式(Statement、Row、Mixed)的选择直接影响着数据安全性与系统性能。本文将从实战角度,深入解

weixin_30599769的博客 400

精雕软件(JDpaint) 5.5 绿色版

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

PowerDNS主从复制实战:基于数据库的高可用DNS架构

DNS服务是网络基础设施的核心组件,其高可用性依赖于可靠的主从数据同步机制。PowerDNS通过原生数据库复制(如MySQL主从)实现强一致性、低延迟、可审计的DNS数据同步,区别于传统AXFR/IXFR或文件同步方案。该机制将DNS从静态配置升级为动态数据服务,支撑读写分离、DNSSEC异步签名、多角色流量分发等现代运维需求。尤其适用于老旧但稳定的生产环境(如Ubuntu 14.04+PowerDNS 3.4.8),在不中断业务前提下构建具备故障自动切换与变更可追溯能力的DNS架构。

weixin_33907511的博客 366

深度学习工具包 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")

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

四层冗余架构:RAID、DRBD、MySQL复制与PostgreSQL高可用选型实战

高可用(High Availability)本质是分层容错设计,而非单一技术堆砌。从存储层物理冗余(RAID)到块设备同步(DRBD),再到数据库服务级复制(MySQL/MariaDB主从与GTID),最终抵达原生高可用架构(PostgreSQL流复制+Patroni),每一层解决特定故障域——RAID应对磁盘损坏,DRBD覆盖主机单点失效,MySQL半同步保障事务级RPO,Patroni实现自治化故障转移。这种分层模型兼顾数据一致性、恢复时效性与运维可控性,广泛应用于金融账务、电商订单、政务云等对连续性要

weixin_33836874的博客 438

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

国产化之 GoldenDB 配置参数调优指南

国产化之 GoldenDB 配置参数调优指南

7DGroup,让技术更有价值! 1820

知识体系之MySQL

mysql

JaweG 5251

Python操作MySQL生产实战:字符集、连接池与参数化防注入

MySQL与Python的集成是Web后端开发的基础能力,其核心在于理解数据库驱动原理、连接生命周期管理及SQL执行安全机制。从字符集配置(如utf8mb4)到连接池调优(maxsize与QPS匹配),再到参数化查询如何通过MySQL协议级预编译抵御SQL注入,每一环节都直接影响系统稳定性与安全性。真实项目中常见的中文乱码、连接泄漏、事务卡死、SSL劫持风险等问题,本质是开发人员对底层协议(如COM_STMT_PREPARE)、服务端配置(wait_timeout、max_allowed_packet)和驱

culuo8053的博客 399
上一篇: openGauss 迁移到 GreatSQL:DataX 全流程实操指南
下一篇: GreatSQL 8.4.4-5 GA(2026-06-30)
GreatSQL社区
博客等级 码龄5年 1210粉丝 390原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值