Docker使用(四)Docker常见问题分析和解决收集整理

24 个 Docker 常见问题处理技巧 启动服务的时候,发现有时候服务之前可以相互连通,而有时启动的多个服务之前却出现了无法访问的情况。平台部署服务的时候,也有时会因为启动问题需要,使启动的服务不直接退出,来手动调试和排查问题原因。中,那么很显然,我们还必须找到一个地方储存文件的元信息,比如文件的创建者、文件的创建日期、文件的大小等等。但是奇怪的是,本地调试的时候发现服务都是可以正常运行的,文件加锁也是没问题的。而是,因为对于分区的。容器在导入或者启动的时候,如果提示磁盘空间不足的,那么多半是真的因为物理磁盘空间真的有问题导致的。... 阅读详情

Docker使用(四)Docker常见问题分析和解决收集整理

五、常见问题

1、 启动异常

【描述】:
在这里插入图片描述

【分析】:[root@localhost ~]# systemctl status docker
在这里插入图片描述

【解决】:

(1)卸载后重新安装,不能解决这个问题。

(2)

vim /lib/systemd/system/docker.service

CentOS 的路径为: /usr/lib/systemd/system/docker.service

修改文件内容:

# ExecStart=/usr/bin/dockerd -H fd://

ExecStart=/usr/bin/dockerd

在这里插入图片描述

备注:不能解决

(3)

进入 /etc/docker,没有daemon.json文件就自己新建一个

{

“registry-mirrors”: [“https://registry.docker-cn.com”]

}

备注:不能解决

(4)防火墙未关闭

解决方法:关闭防火墙即可。

systemctl stop firewalld

[root@localhost system]# sudo systemctl restart docker

备注:解决。

解决过程:

【1】 执行指令

​ [root@localhost system]# journalctl -xe

在这里插入图片描述

【2】查询 ERROR: COMMAND_FAILED: ‘/sbin/iptables -w2 -t filter -C DOCKER-ISOLATION-STAGE-2 -j RETURN’ failed: iptables: Bad

分析:

https://www.cnblogs.com/lijinze-tsinghua/p/8809838.html

由于防火墙未关闭导致。

============================================================================

2、 启动异常 2

【描述】:docker启动异常localhost.localdomain systemd[1]: start request repeated too quickly for docker.service

【解决】:

https://blog.csdn.net/qq_35648576/article/details/105953090

重启docker服务即可解决

# systemctl restart docker

============================================================================

3、docker启动不起来

【描述】:防火墙(firewalld)打开时候, docker启动不起来

在这里插入图片描述

【解决】:

reboot后,firewall自动启动(因为执行了这个 systemctl enable firewalld.service 开机启动),导致(systemctl start docker)执行失败,报上面错。

在这里插入图片描述

如何解决?:

分析:

(1)https://www.widuu.com/docker/installation/centos.html#installing-docker-centos-7

​ firewalld 和 iptables 都不是防火墙,它们只是防火墙的管理程序,真正的防火墙是内核的netfilter。CentOs 6 中使用iptables来管理防火墙,到了CentOs 7 默认使用firewalld来管理防火墙,但需要注意的是 firewalld 的底层还是调用 iptables 的,firewalld在iptables的基础上加了许多很好用的功能。

​ firewalld 是系统服务,有守护进程。iptables 只是一个工具,不是服务。

CentOS-7 中介绍了 firewalld,firewall的底层是使用iptables进行数据过滤,建立在iptables之上,这可能会与 Docker 产生冲突。

​ 当 firewalld 启动或者重启的时候,将会从 iptables 中移除 DOCKER 的规则,从而影响了 Docker 的正常工作。

​ 当你使用的是 Systemd 的时候, firewalld 会在 Docker 之前启动,但是如果你在 Docker 启动之后再启动 或者重启 firewalld ,你就需要重启 Docker 进程了。

(2) https://www.cnblogs.com/lemon-le/p/12976999.html

1、netfilter与iptables的关系

Netfilter是在Linux内核中的一个防火墙框架,用于管理网络数据包,不仅具有网络地址转换(NAT)的功能,也具有数据包内容修改,以及数据包过滤等防火墙功能。利用在用户空间的应用软件iptables等来控制Netfilter(iptables只是应用软件,工具)。

在这里插入图片描述

2、iptables与firewalld的关系

firewalld和iptables一样都是应用软件,是工具,但是他们的底层还是先通过iptables。

3、docker与firewalld、iptables的关系

1)docker安装完成后,会自动接管iptables或者firewalld,在docker run的时候,会自动往iptables里加入规则;所以当iptables重启后会丢失,只有再重启docker就好了的原因。

2)当使用Systemd 的时候, firewalld 会在 Docker 之前启动,但是如果你在 Docker 启动之后再启动 或者重启 firewalld ,就需要重启 Docker 进程了。

iptables详解(1):iptables概念

iptables是按照规则来办事的,规则(rules),其实就是网络管理员预定义的条件,规则一般的定义为”如果数据包头符合这样的条件,就这样处理这个数据包”。规则存储在内核空间的信息包过滤表中,这些规则分别指定了源地址、目的地址、传输协议(如TCP、UDP、ICMP)和服务类型(如HTTP、FTP和SMTP)等。当数据包与规则匹配时,iptables就根据规则所定义的方法来处理这些数据包,如放行(accept)、拒绝(reject)和丢弃(drop)等。配置防火墙的主要工作就是添加、修改和删除这些规则。

============================================================================

4、Networking will not work

【描述】:docker run hello-world 提示

WARNING: IPv4 forwarding is disabled. Networking will not work.

在这里插入图片描述

【解决】:
配置转发:

vim /etc/sysctl.conf

#配置转发
net.ipv4.ip_forward=1

#重启服务,让配置生效
systemctl restart network

#查看是否成功,如果返回为“net.ipv4.ip_forward = 1”则表示成功

sysctl net.ipv4.ip_forward

=======================================================

5、外部无法访问对应宿主机端口

【描述】:

建docker容器的时候,做了端口映射到宿主机, 防火墙已关闭, 但是外部始终无法访问宿主机端口?

这种情况基本就是因为宿主机没有开启ip转发功能,从而导致外部网络访问宿主机对应端口是没能转发到 Docker Container 所对应的端口上。

【解决】:

Linux 发行版默认情况下是不开启 ip 转发功能的。这是一个好的做法,因为大多数人是用不到 ip 转发的,但是如果架设一个 Linux 路由或者VPN服务我们就需要开启该服务了。

=======================================================

在 Linux 中开启 ip 转发的内核参数为:net.ipv4.ip_forward,查看是否开启 ip转发:

检查宿主机的ip_forward:

# cat /proc/sys/net/ipv4/ip_forward // 0:未开启,1:已开启

所以具体的解决方案就是修改ip_forward的值为1

=======================================================

临时解决:

打开ip转发功能, 下面两种方法都是临时打开ip转发功能!

# echo 1 > /proc/sys/net/ipv4/ip_forward

# sysctl -w net.ipv4.ip_forward=1

=====================================================================

永久生效的ip转发:修改/etc/sysctl.conf文件

# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

# sysctl -p /etc/sysctl.conf // 立即生效

Linux 系统中也可以通过重启网卡来立即生效 (修改sysctl.conf文件后的生效)

# service network restart // CentOS 6

# systemctl restart network // CentOS 7

# systemctl restart docker.service

5.2 [CentOS7 下部署 Iptables 环境纪录(关闭默认的firewalle)

1、关闭firewall:

[root@localhost ~]# systemctl stop firewalld.service //停止firewall

[root@localhost ~]# systemctl disable firewalld.service //禁止firewall开机启动

2、安装iptables防火墙

[root@localhost ~]# yum install iptables-services //安装

[root@localhost ~]# vim /etc/sysconfig/iptables //编辑防火墙配置文件

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMIT

[root@localhost ~]# systemctl restart iptables.service //最后重启防火墙使配置生效

[root@localhost ~]# systemctl enable iptables.service //设置防火墙开机启动 [root@localhost ~]# iptables -L //查看防火墙规则,默认的是-t filter,如果是nat表查看,即iptables -t nat -L

3、关闭SELINUX

[root@localhost ~]# vim /etc/selinux/config

#SELINUX=enforcing // 注释掉

#SELINUXTYPE=targeted // 注释掉

SELINUX=disabled // 增加

[root@localhost ~]# setenforce 0 //使配置立即生效

=======================================================

6、 iptables: No chain/target/match by that name

【描述】:docker启动container的时候出现iptables: No chain/target/match by that namece/p/5799}

在这里插入图片描述

【解决】:

[root@localhost ~]# systemctl restart docker

分析:

​ 如果在启动docker service的时候网关是关闭的,那么docker管理网络的时候就不会操作网管的配置(chain docker),然后网关重新启动了,导致docker network无法对新container进行网络配置,也就是没有网管的操作权限,做重启处理。

​ 使用的centos7服务器,在部署docker的过程中,因端口问题有启停firewalld服务,在centos7里使用firewalld代替了iptables。在启动firewalld之后,iptables还会被使用,属于引用的关系。所以在docker run的时候,iptables list里没有docker chain,重启docker engine服务后会被加入到iptables list里面。(有必要深入研究一下docker network)

=======================================================

7、Docker 容器访问网关不通

问题描述:

1、安装好docker后,docker0地址:172.17.0.1
2、创建两个容器a,b后,ip分别为:172.17.0.2,172.17.0.3
3、宿主机无法ping通2个容器的ip地址,进入容器后也无法ping通docker0地址, 但容器间能互相ping通(在a内能ping通b,b内能ping通a),且无法ping通外网地址(但默认docker容器内是可以ping通外网的)

分析:

参考了很多帖子,各种原因都分析了,甚至classiclink问题也考虑了,最后通过阿里云工程师帮忙日志分析,才发现是docker 加载内核的bridge.ko 驱动异常,导致docker0 网卡无法转发数据包,也就是系统内核的网桥模块bridge.ko 加载失败导致的,一般情况下这种场景的确很少见。

解决措施:

升级centos内核,或直接升级系统解决了。

解决过程:

  1. 查询内核版本

查询120的服务器172.41.0.120 内核版本

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

内核版本是3.10太低了,导致Docker0不转发数据包

  1. 升级内核版本

步骤一:登录服务器,查看当前内核版本为3.10

cat /etc/redhat-release

步骤二:

yum --disablerepo="*" --enablerepo="elrepo-kernel" list available查看可安装的内核版本

下载内核源

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

步骤三:安装最新内核版本

yum --enablerepo=elrepo-kernel install -y kernel-lt

步骤四:查看当前可用内核

cat /boot/grub2/grub.cfg |grep menuentry

步骤五:设置操作系统从新内核启动

grub2-set-default "CentOS Linux (4.4.221-1.el7.elrepo.x86_64) 7 (Core)"

查看内核启动项是否修改

grub2-editenv list

步骤六:最后重启生效

reboot

3、再次查询验证

自定义了mynet01

  • subnet = 172.15.0.0/24
  • gateway = 172.15.0.1
[root@localhost ~]# docker network create --subnet=172.15.0.0/24 --gateway=172.15.0.1 mynet01

[root@localhost ~]# docker run -d --name tomcat_mynet01_01 -p 8992:8080 --net mynet01 tomcat

[root@localhost ~]# docker exec -it tomcat_mynet01_01  ping 172.15.0.1

在自定义网络中,容器内可以ping的通网关的,在默认docker0网络中也是可以ping的通,这里不截图了。

总结:

  • linux内核版本这个问题比较隐蔽,不好找,还是找了大牛的解决方案分析测试的。

  • Docker网络是很重要的部分,需要深入分析。

=======================================================

8、容器内没有yum命令_无法使用vi命令

【描述】:docker容器内没有yum命令_Docker容器里无法使用vi命令

【解决办法】:

  1. apt-get update
  2. apt-get install vim
docker 常见故障(五十个) 解决方式:docker-containerd-ctr --address /run/docker/containerd/docker-containerd.sock --namespace c rm <容器hash_id>解决方式:pip install -i https://pypi.douban.com/simple docker-compose。原因:Docker使用写时复制策略,所以chown命令执行时,会将上层镜像文件全部复制到当前层,然后再修改权限,再写入文件系统。 阅读详情

相关推荐

24个Docker常见问题处理技巧

启动服务的时候,发现有时候服务之前可以相互连通,而有时启动的多个服务之前却出现了无法访问的情况。平台部署服务的时候,也有时会因为启动问题需要,使启动的服务不直接退出,来手动调试和排查问题原因。中,那么很显然,我们还必须找到一个地方储存文件的元信息,比如文件的创建者、文件的创建日期、文件的大小等等。但是奇怪的是,本地调试的时候发现服务都是可以正常运行的,文件加锁也是没问题的。而是,因为对于分区的。容器在导入或者启动的时候,如果提示磁盘空间不足的,那么多半是真的因为物理磁盘空间真的有问题导致的。

wuds_158的博客 1389

修改了 /usr/lib/systemd/system/docker.service 之后,Docker 无法启动问题的解决方法

通过 vi /usr/lib/systemd/system/docker.service 修改了 docker 配置之后,接着执行以下两个命令重启 Docker: systemctl daemon-reload systemctl restart docker 运行结果: 提示我们使用 journalctl -xe 命令来查看更详细的出错日志: (1)原因分析 日志中写的很清楚,配置的 Docker 镜像私服不可用(invalid mirror)。 (2)解决 修改并保存 /etc/docker

读万卷书,行万里路 1万+

本地如何使用docker部署和使用Xinference

本地如何使用docker部署和使用Xinference

jsyzliuyu的博客 1万+

docker安装配置

一、docker配置参数 docker.service文件内容 /usr/lib/systemd/system/docker.service [Unit] Description=Docker Application Container Engine Documentation=http://docs.docker.com After=network.target Wants=docker-storage-setup.service Requires=docker-cleanup.timer [Servi

wq1205750492的博客 1万+

Delft3D从入门到实践:安装、编译与首次模拟指南

本文为Delft3D初学者提供了一份详尽的从零开始指南。内容涵盖软件获取、许可证申请、图形界面安装、核心计算内核的编译环境搭建与编译步骤,以及最终整合运行首个水动力模拟的全流程。重点解决了Windows系统下Delft3D安装与编译的常见问题,帮助用户快速上手这一开源水动力与泥沙输运模拟工具。

weixin_29303701的博客 533

MCP详解:手把手教你理解和如何使用各种开源MCP服务

MCP 作为一种开放协议,为 AI 模型与外部世界的连接提供了标准化的解决方案。它不仅降低了开发门槛,还极大地扩展了 AI 应用的边界。无论是开发者还是普通用户,都可以通过 MCP 更高效地利用 AI 技术,实现更多智能化的功能。

王哥儿聊AI的博客 6036

【Docker】Docker 常见问题及解决方案

本文总结了 Docker 使用中常见的问题及解决方案,希望能帮助您更有效地使用 Docker。在实际应用中,您可能还会遇到其他问题,建议参考 Docker 官方文档和社区资源获取更多信息。

人生苦短,睡觉要紧,睡醒再说 2872

Maxwell个人初学经验及资料分享

前段时间学习了课题组基于Maxwell所建立的模型,因为以前从来没有使用过,只是按照一步一步记忆了操作,但总觉得不熟悉,我想是缺乏对这个软件整体的了解,真正想上手只会这一个模型也没有办法扩展。但是我感觉这些有限元分析软件学习起来应该有一些共性,基于以前对COMSOL学习的一点经验,我就在官网和其他网站找了一些学习资源构成一条基础入门之路,也可能有更好的资源,仅代表个人观点做一下分享。以上就是本人对该软件初步学习的一点理解,跟着这样的操作不到一个星期就能初步的掌握。...

怎么又是萝卜的博客 5618

在Docker中运行的ZooKeeper无法使用四字命令解决办法

前阵子写过一篇文章,用来记录如何在docker中启动ZooKeeper的单机或者集群节点,最近收到一个issue,大意是说项目启动后,测试ZK的四字命令无效,这篇文章记录一下解决办法 ZK四字命令 四字命令其实就是通过类似 echo stat | nc 127.0.0.1 2181 这样的指令,来与zk节点交互,获取或者设置数据的指令 zk四字命令列表: ...

AroudSoft的博客 1723

linux下redhat6.8(理论是都适用)安装oracle12c---详细教程

1、配置yum源 1)、删除Redhat自带的yum: (2)、上传centos的yum包,并按照顺序安装,所需的rpm包通过点击这里获取(放在oracle文件中的centos yum):上传到linux中 进行安装 yum包链接:https://pan.baidu.com/s/1TxciCWEd7d-d4kGoea0L1w 提取码:eufp `` --注意后面两个安装包一起安装 ## 3)、更改系统yum源: 编辑rhel-source.repo文件,将其中的$releas

z931407229的博客 1144

ESP32-S3打造离线语音助手:从零部署自定义唤醒词与本地大模型推理【实战指南】

本文详细介绍了如何利用ESP32-S3芯片打造离线语音助手,包括自定义唤醒词训练与本地大模型推理的实战指南。通过硬件架构解析、音频处理优化及性能调优技巧,实现低延迟、高隐私保护的语音交互方案,特别适合智能家居和物联网应用。

weixin_30296405的博客 600

Docker中使用Zookeeper项目常见问题解决方案

Docker中使用Zookeeper项目常见问题解决方案 项目基础介绍和主要编程语言 该项目是使用Docker技术来部署和管理Zookeeper服务的开源项目。Zookeeper是一个开源的分布式协调服务,它为分布式应用提供了高效且可靠的协调服务,支持配置维护、命名服务、分布式同步和组服务等。该项目提供了一个Docker镜像,可以帮助用户快速搭建和维护Zookeeper集群。 主要的编程语言为Do...

gitblog_01160的博客 705

metahuman 下载材质 脸部灰白 脸部过亮

metahuman 下载材质 脸部灰白 脸部过亮

jacke121的专栏 240

Docker Emacs 配置与使用常见问题解决方案

Docker Emacs 配置与使用常见问题解决方案 1. 项目基础介绍及主要编程语言 docker-emacs 是一个开源项目,它提供了一个基于 Docker 的环境来运行 Emacs,这是一种广泛使用的文本编辑器,适用于编程和其他文本编辑任务。该项目旨在简化 Emacs 的安装过程,通过创建一个预先配置好的 Docker 容器来避免在本地机器上手动安装和配置 Emacs 的各种依赖。 主要编程...

gitblog_00694的博客 767

【Linux】Windows11 安装 WSL2 并运行 Ubuntu 22.04 详细操作步骤

Windows 11 安装 WSL2 和 Ubuntu 22.04 指南 本文详细介绍在 Windows 11 上安装 WSL2 和 Ubuntu 22.04 的完整步骤,包括: WSL2 与 VirtualBox 的性能对比优势 系统版本检查与升级方法 两种安装方式(一键安装和手动安装) Ubuntu 22.04 的安装与配置 存储位置管理及迁移技巧 常用 WSL2 命令速查表 文章还提供了性能优化建议和常见问题解决方案,适合开发者和 Linux 爱好者快速搭建高效的开发环境。

No8g攻城狮的博客 2万+

遥感影像道路提取算法——SGCN

用于从高分辨率遥感图像(TGRS)中提取复杂环境中道路的分割深度可分离图卷积网络摘要:高分辨率遥感图像的道路信息在各个领域得到广泛应用,基于深度学习的方法有效地显示了较高的道路提取性能。然而,在高分辨率遥感图像中,检测柏油路封闭或树木覆盖的道路,仍存在一些挑战,限制了提取的准确性:1)道路之间的阶级内差异较大,城市物体,特别是道路和建筑物之间的阶级间差异不明显;2)被树木、阴影和建筑物遮挡的道路难以提取;3)道路缺乏高精度遥感数据集。

littleyy666的博客 3843

Docker 项目常见问题解决方案

Docker 项目常见问题解决方案 Docker 是一个开源的应用容器引擎,它允许开发者打包他们的应用以及应用的依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。本项目主要是用 Go 语言编写的。 下面是针对新手在使用 Docker 项目时可能会遇到的三个常见问题及其解决步骤: 1. 如何安装 Docker 问题现象: 新手用户在尝试安装 Docker 时可能...

gitblog_00762的博客 941

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

Docker Machine VMware Workstation 项目常见问题解决方案

Docker Machine VMware Workstation 项目常见问题解决方案 1. 项目基础介绍及主要编程语言 Docker Machine VMware Workstation 是一个开源项目,旨在为 Docker Machine 提供一个本地 VMware Workstation 驱动。该驱动使得用户能够在 VMware Workstation 上创建 Docker 主机。项目主要...

gitblog_00236的博客 739

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

使用 Docker Compose 部署 ngrok 内网穿透服务及常见问题解决

ngrok 是一个强大的内网穿透工具,可以将本地服务暴露到公网,方便调试和分享。通过 Docker Compose 部署 ngrok 可以简化配置和管理过程。然而,在实际操作中,可能会遇到一些配置问题。本文将详细介绍如何使用 Docker Compose 部署 ngrok,并解决常见的错误。通过 Docker Compose 部署 ngrok 可以大大简化内网穿透服务的配置和管理。本文详细介绍了配置文件的编写方法,并提供了常见问题的解决方案。如果你在部署过程中遇到其他问题,欢迎在评论区留言讨论!

加入“Super Entity”,与全能开发团队共探AI智能体与数字人项目,开启前沿技术之旅。 1508

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Docker Strapi 项目常见问题解决方案

Docker Strapi 项目常见问题解决方案 1. 项目基础介绍和主要编程语言 Docker Strapi 是一个基于 Docker 容器化的 Strapi 项目,Strapi 是一个开源的 Headless Content Management System (CMS)。该项目允许开发者通过 Docker 容器轻松部署 Strapi 应用。主要编程语言是 JavaScript,Strapi ...

gitblog_01029的博客 1073

Docker Nginx项目使用常见问题解决方案

Docker Nginx项目使用常见问题解决方案 1. 项目简介 Docker Nginx是一个基于Nginx的Docker镜像,用于轻松托管静态网站。该项目旨在提供一种便捷的方式,让用户可以快速地在Docker环境中部署和运行Nginx服务器,以服务于静态文件。该项目使用MIT许可协议,由Kyle A. Mathews维护。 主要编程语言 该项目主要涉及的编程语言是Dockerfile以及一些N...

gitblog_00251的博客 976

Elasticsearch 和 Kibana 的 Docker 开发环境常见问题解决方案

Elasticsearch 和 Kibana 的 Docker 开发环境常见问题解决方案 项目基础介绍 elastic-docker 项目是一个用于在 Docker 环境中设置 Elasticsearch 和 Kibana 的开发环境的示例项目。该项目使用 Docker Compose 来管理容器,并提供了官方和非官方的配置示例。主要编程语言为 YAML,用于定义 Docker Compose 配...

gitblog_00408的博客 1077

Ethereum Docker 项目常见问题解决方案

Ethereum Docker 项目常见问题解决方案 1. 项目基础介绍和主要编程语言 Ethereum Docker 项目旨在通过 Docker 容器快速创建 Ethereum 开发和测试的单节点或多节点集群。该项目的主要目的是简化 Ethereum 开发环境的搭建过程,使得开发者能够快速启动和测试 Ethereum 节点。 该项目主要使用以下编程语言和工具: Docker: 用于容器化 Et...

gitblog_00309的博客 1021

Docker-WebUI 项目常见问题解决方案

Docker-WebUI 项目常见问题解决方案 1. 项目基础介绍和主要编程语言 Docker-WebUI 是一个开源项目,它为 Docker 提供了一个基于 Web 的用户界面。通过这个界面,用户可以轻松管理 Docker 容器和镜像,执行如启动、停止、重启、删除容器等操作,并且可以查看容器的日志、统计信息和差异。项目的主要编程语言是 Go,它使用了 Docker 的 API 来实现这些功能。 ...

gitblog_00001的博客 1213

PrestaShop Docker 项目常见问题解决方案

PrestaShop Docker 项目常见问题解决方案 项目基础介绍 PrestaShop Docker 项目是一个用于部署和运行 PrestaShop 电子商务平台的 Docker 容器化解决方案。PrestaShop 是一个开源的电子商务平台,广泛用于创建和管理在线商店。该项目的主要目的是简化 PrestaShop 的部署过程,使其能够在 Docker 环境中快速启动和运行。 该项目主要使用...

gitblog_00917的博客 847
上一篇: 程序员职业赛道探秘:从前端花园起步、迈过后端洞穴,最后到达数据科学的神秘殿堂
下一篇: SqlServer2008(R2)(一)SqlServer2008(R2)经典宝藏操作收集整理
JasonHuan1123
博客等级 码龄16年 2701粉丝 53原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JasonHuan1123

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值