【日常积累】Linux基本命令(一)

Mysql8.2自动备份脚本及3种备份出错解决方案 mysql到了8以后安全性大大增加,备份也是个麻烦事,我们今天来解决这个问题 一、自动备份 为了方便维护,我们将要备份的信息存入一个配置文件db.conf localhost root password db1 localhost root password db2 然后写一个自动备份脚本,调用配置文件信息进行备份,脚本名为auto.sh 内容如下: #!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin: 阅读详情

今天分享一下Linux中常用的一些基础命令

目录及文件的基本操作

cd

描述:cd命令的作用是切换当前工作目录

#切换到某个指定的工作目录
[root@VM-4-6-centos ~]# cd /usr/lib/systemd/system
#切换至当前目录的上一层目录
[root@VM-4-6-centos system]# cd ..
#切换至上一次的工作目录
[root@VM-4-6-centos systemd]# cd -
/usr/lib/systemd/system
# 切换到当前用户的家目录
[root@VM-4-6-centos system]# cd 
[root@VM-4-6-centos ~]# 

pwd

描述:pwd命令的作用是显示当前工作目录的名称
用法::pwd [选项]…
选项::-P显示链接的真实路径

[root@VM-4-6-centos ~]# cd /tmp/
[root@VM-4-6-centos tmp]# mkdir -p a/b/c/d
[root@VM-4-6-centos tmp]# cd a/b/c/d/
#创建一个软连接
[root@VM-4-6-centos tmp]# ln -s  /tmp/ a/b/c/d/abcd
[root@VM-4-6-centos d]# ls
abcd
[root@VM-4-6-centos d]# cd abcd/
[root@VM-4-6-centos abcd]# pwd
/tmp/a/b/c/d/abcd
#注意和上面的区别,加了-P选项显示了真实的路径
[root@VM-4-6-centos abcd]# pwd -P
/tmp

ls

描述:命令的作用是显示目录与文件信息
用法::ls [选项]… [文件/目录]…
选项::-a 显示所有的信息,包括隐藏文件与目录。

  • -d 显示目录本身的信息,而非目录下的文件文件夹的信息。
  • -h 人性化显示容量信息。
  • -l 长格式显示详细信息。
  • -c 显示文件或目录属性最后修改的时间。.
  • -u 显示文件或目录最后被访问的时间。
  • -t 以修改时间排序,默认按文件名称排序。
[root@VM-4-6-centos ~]# cd /tmp/
#显示当前目录下的文件和文件夹
[root@VM-4-6-centos tmp]# ls
stargate.lock  tat_agent  test.sh
#指定显示某个目录下的子文件和目录
[root@VM-4-6-centos tmp]# ls /etc/ssh/
moduli  ssh_config  sshd_config  ssh_host_dsa_key  ssh_host_dsa_key.pub  ssh_host_ecdsa_key  ssh_host_ecdsa_key.pub  ssh_host_ed25519_key  ssh_host_ed25519_key.pub  ssh_host_rsa_key  ssh_host_rsa_key.pub
#查看包括以. 开头的隐藏文件和目录
[root@VM-4-6-centos tmp]# ls -a
.  ..   .font-unix  .ICE-unix  tat_agent  test.sh  .Test-unix  .X11-unix  .XIM-unix
#查看文件和目录的详细信息
[root@VM-4-6-centos tmp]# ls -l
total 12
drwxr-xr-x 4 root root 4096 Aug 14 16:25 tat_agent
-rw-r--r-- 1 root root  369 Aug 14 20:37 test.sh
#查看指定目录自身的详细信息
[root@VM-4-6-centos tmp]# ls -ld /root/
dr-xr-x---. 8 root root 4096 Aug 15 18:17 /root/
#人性化显示容量占用信息
[root@VM-4-6-centos tmp]# ls -lh
total 12K
drwxr-xr-x 4 root root 4.0K Aug 14 16:25 tat_agent
-rw-r--r-- 1 root root  369 Aug 14 20:37 test.sh
# 查看指定文件的属性变更时间
[root@VM-4-6-centos tmp]# ls -lc test.sh 
-rw-r--r-- 1 root root 369 Aug 14 20:37 test.sh
#查看指定文件最后访问时间
[root@VM-4-6-centos tmp]# ls -lu test.sh 
-rw-r--r-- 1 root root 369 Aug 16 10:33 test.sh
#查看文件的信息并以修改时间进行排序,默认倒序
[root@VM-4-6-centos tmp]# ls -lt
total 12
-rw-r--r-- 1 root root  369 Aug 14 20:37 test.sh
drwxr-xr-x 4 root root 4096 Aug 14 16:25 tat_agent

mkdir

描述:创建目录。
选项:-p 创建多级目录。

[root@VM-4-6-centos tmp]# mkdir a
[root@VM-4-6-centos tmp]# mkdir -p a/b/c/d

touch

描述:创建或修改文件时间。

[root@VM-4-6-centos tmp]# touch  a.txt

如果a.txt不存在,则创建,如果已存在,则更新文件所有的时间为当前系统时间。

cp

描述:复制文件与目录
用法:cp[选项]源目标
选项: -r递归,复制子文件与子目录,一般复制目录时使用。

#复制文件/etc/ssh/sshd_config至/ tmp目录下
[root@VM-4-6-centos tmp]# cp /etc/ssh/sshd_config /tmp/
#复制文件/etc/ssh/sshd_config至/目录下并改名为sshd.config
[root@VM-4-6-centos tmp]# cp /etc/ssh/sshd_config /tmp/sshd.config
#复制目录/etc/ssh/至/tmp/目录下
[root@VM-4-6-centos tmp]# cp  -r /etc/ssh/ /tmp/

rm

描述:删除文件或目录
用法: rm [选项]…文件…
选项:

  • -f 不提示,强制删除。
  • -i 删除前,提示是否删除。不指定默认就会提示
  • -r 删除目录以及目录下的所有内容。
# 强制删除不提示
[root@VM-4-6-centos tmp]# rm -f sshd_config 

#删除默认提示
[root@VM-4-6-centos tmp]# rm  sshd.config 
rm: remove regular file ‘sshd.config’? 

#删除目录且不提示
[root@VM-4-6-centos tmp]# rm -rf  ssh

mv

描述:移动(重命名)文件或目录。

#将test.sh 改名为 test.txt
[root-4-6-centos tmp]# mv test.sh  test.txt
#将test.txt移至/root目录下
[root-4-6-centos tmp]# mv test.txt /root/

find

描述:搜索文件或目录。
用法:find [命令选项] [路径] [表达式选项]
选项:

  • -empty 查找空白文件或目录。
  • -group 按组查找。
  • -name 按名称查找。
  • -iname按名称查找,不区分大小写。
  • -mtime 按修改时间查找。
  • -size 按容量大小查找。
  • -type 按档案类型查找, 文件(f)、 目录(d)、 设备(b,c)、 链接(I) 等。
  • -user 按用户查找。
  • -exec 对找到的文件执行命令。
  • -a 并且。
  • -o 或者。
#查找当前目录下名为test.txt的文件
[root@VM-4-6-centos tmp]# find . -name test.txt 
./test.txt
#当前目录下忽略大小写查找文件
[root@VM-4-6-centos tmp]# find . -iname TEST.TXT
./test.txt
# 在/var/log目录下查找以log结尾的文件
[root@VM-4-6-centos tmp]# find  /var/log/ -name *.log
/var/log/audit/audit.log
/var/log/boot.log
/var/log/qcloud_action.log
/var/log/cloud-init-output.log
/var/log/cloud-init.log
/var/log/yum.log
/var/log/tuned/tuned.log

#查找所有内容为空的文件,包括空文件夹和内容为空的文件
[root@VM-4-6-centos tmp]# find  / -empty 
#只查找文件内容为空的所有文件
[root@VM-4-6-centos tmp]# find  / -empty -type f
#查找所有属于nginx组的文件
[root@VM-4-6-centos tmp]# find / -group nginx

#当前目录下查找3天前被修改过的文件
[root@VM-4-6-centos tmp]# find . -mtime +3
./.XIM-unix
./.font-unix
./.X11-unix
./.ICE-unix
./.Test-unix
#当前目录下查找2天内被修改过的文件
[root@VM-4-6-centos tmp]# find . -mtime -2
./tat_agent
./tat_agent/commands
./tat_agent/commands/202308
./tat_agent/logs
./tat_agent/logs/invt-7k2m4fa1b6.log
./test.txt
#当前目录下查找2天前的当天被修改过的文件
[root@VM-4-6-centos tmp]# find . -mtime 2
./stargate.lock
#当前目录下查找大小大于10M的文件
[root@VM-4-6-centos tmp]# find . -size +10M
#当前目录下查找普通文件
[root@VM-4-6-centos tmp]# find . -type f
./tat_agent/logs/invt-7k2m4fa1b6.log
./test.txt
./stargate.lock
#当前目录下查找普通文件,并执行后面的命令。也可以是其他合适的命令。注意格式正确
[root@VM-4-6-centos tmp]# find . -type f -exec ls -l {} \;
-rw-r----- 1 root root 0 Aug 14 16:25 ./tat_agent/logs/invt-7k2m4fa1b6.log
-rw-r--r-- 1 root root 369 Aug 14 20:37 ./test.txt
-rw-r--r-- 1 root root 0 Aug 13 15:12 ./stargate.lock

du

描述:计算文件或目录的容量。
用法: du [选项… [文件或目录]…
选项:

  • -h人性化显示容量信息。
  • -s仅显示总容量。
#查看/root目录总的容量占用信息
[root-4-6-centos tmp]# du -sh /root/
224K    /root/

查看文件内容

cat

描述:查看文件内容。
用法:cat [选项]… [文件]…
选项:

  • -b 显示行号,空白行不显示行号。
  • -n 显示行号,包括空白行。
[root-4-6-centos ~]# cat -b /etc/ssh/sshd_config
[root-4-6-centos ~]# cat -n /etc/ssh/sshd_config 

more

描述:分页查看文件内容,通过空格键查看下一-页,q键则退出查看。

[root@VM-4-6-centos ~]# more /var/log/messages 

less

描述:分页查看文件内容,空格(下一页)、方向键(上下回翻)、q键(退出查看)。

[root@VM-4-6-centos ~]# less /var/log/messages 

head

描述:查看文件头部内容,默认显示前10行。
用法:head [选项… [文件…
选项::

  • -c nK 显示文件前nKB的内容。
  • -n 显示文件前n行的内容。
[root@VM-4-6-centos ~]# head -c 1k /var/log/messages 
[root@VM-4-6-centos ~]# head -20 /var/log/messages 

tail

描述:查看文件的尾部内容,默认显示末尾10行。
用法:tail [选项]… [文件]
选项:

  • -cnK显示文件末尾 nKB的内容。
  • -n 显示文件末尾n行的内容。
  • -f 动态显示文件内容,按Ctrl+C组合键退出。
[root@VM-4-6-centos ~]# tail -c 1k /var/log/messages 
[root@VM-4-6-centos ~]# tail -n 20 /var/log/messages 
[root@VM-4-6-centos ~]# tail -f /var/log/messages 
[root@VM-4-6-centos ~]# tailf  /var/log/messages 

wc

描述:显示文件的行、单词与字节统计信息。
用法::we [选项]… [文件]…
选项:

  • -c 显示文件字节统计信息。
  • -l 显示文件行数统计信息。
  • -w 显示文件单词统计信息。
#默认统计行数、单词数、字节数
[root@VM-4-6-centos ~]# wc -l  /var/log/messages 
98534 /var/log/messages
[root@VM-4-6-centos ~]# wc -w  /var/log/messages 
1082239 /var/log/messages
[root@VM-4-6-centos ~]# wc -c  /var/log/messages 
7410879 /var/log/messages
[root@VM-4-6-centos ~]# wc /var/log/messages 
  98534 1082239 7410879 /var/log/messages

grep

描述:查找关键词并打印匹配的行。
用法:grep [选项]匹配模式[文件]…
选项:

  • -i忽略大小写。
  • -v取反匹配。
  • -w匹配单词,如果是单词的一部分也不会过滤出来
  • -color 显示颜色,默认就会显示颜色
[root@VM-4-6-centos ~]# grep error /var/log/messages 
[root@VM-4-6-centos ~]# grep --color error /var/log/messages 
[root@VM-4-6-centos ~]# grep -i error /var/log/messages 
[root@VM-4-6-centos ~]# grep -w hell /var/log/messages  #技术有hello的单词也不会显示出来
[root@VM-4-6-centos ~]# grep -v error /var/log/messages 

echo

描述:显示一行指定的文本。
用法:echo [选项]… [字符串]…
选项:

  • -n 不输出换行,默认echo输出内容后会换行。
  • -e 支持反斜线开始的转义字符,屏蔽反斜线后面字符的原本含义。如果使用-e选项,则可以识别如下字符序列的特殊含义。
    • \ 反斜线。
    • \a 报警器。
    • \b 退格键。
    • \c 不生成格外输出,默认echo会自动添加换行。等同于-n选项
    • \f 输入表单格式,换行后保留光标位置。
    • \n 换行。
    • \t 生成水平Tab。.
    • \v 生成垂直Tab。
[root@VM-4-6-centos ~]# echo -e "\\"
\
[root@VM-4-6-centos ~]# echo -e "\a"
[root@VM-4-6-centos ~]# echo -e "11\b22"
122

更多关 于Linux的知识请前往博客主页查看,编写过程中可能由于能力有限难免出现问题,敬请指出,谢谢。

基本素质提升(一)----日常/命令积累 这个主题主要带大家学习一下日常开发所使用的命令及相关知识,会持续更新 阅读详情

相关推荐

360加固DEX解密与ELF修复技术解析

本文深入解析了360加固APK的逆向分析技术,重点探讨了其DEX解密与ELF文件修复的核心流程。通过动态调试与Frida脚本,详细拆解了壳的启动机制、反调试绕过、自实现Linker技术,并还原了基于RC4和自定义算法的多层DEX解密过程,为移动安全研究人员提供了实用的实战分析思路。

alice7model的博客 713

Linux文件搜索命令学习

你必须非常努力,才能看起来毫不费力! 微信搜索公众号[ 漫漫Coding路 ],一起From Zero To Hero ! 前言 本篇文章主要讨论Linux中的文件搜索命令,大家一起来学习吧! find 命令格式 find 路径 选项 参数 [ -exec -ok command {} \;] 命令描述 用来在指定目录下查找文件 不填写路径,默认在当前目录下查找 如果不使用选项参数,则find命令将在当前目录下查找子目录与文件,并且将查找到的子目录和文件全部进行显示 常用选项 -name.

u012948302的专栏 1163

人工势场法三大致命缺陷?我用ROS+Gazebo做了组对比实验

本文通过ROS与Gazebo仿真实验,深入剖析了人工势场法(APF)在机器人路径规划中的三大经典问题:局部最小值、目标不可达和路径震荡。文章不仅复现了这些缺陷,还对比测试了虚拟目标点法、改进斥力场及运动平滑等主流改进方案,为工程选型提供了基于数据的实用建议。

dapp9builder的博客 224

Linux 使用指南

Linux 使用指南

weixin_41890483的博客 392

《寻秦OL》.ani动画逆向解析:二进制结构与Unity重实现

动画文件格式是游戏资源逆向的核心入口,其本质是一组按特定规则组织的二进制数据流。理解魔数识别、字节序、字段对齐与差分编码等底层原理,是解析非标准格式的关键前提。技术价值在于绕过黑盒协议,直接从静态客户端提取可验证的原始语义;典型应用场景包括老游戏复刻、美术资产抢救、引擎跨平台迁移及教学级逆向训练。本文以《寻秦OL》的`.ani`文件为实例,深入剖析其C风格结构布局、GB2312中文命名、16位定点数旋转表示及帧主序差分存储机制,并基于C#在Unity中完成从字节流到AnimationClip的端到端重建,覆

weixin_30368981的博客 654

EEGLAB数据预处理基本流程GUI实操指南

按钮,会出现如上图所示的长条形对话框,方框里面是所有电极的名称,这时将需要的剔除的电极选择上,如上图,我选择了 VEOG这个电极(该电极表示是垂直眼电),然后点“OK”,在弹出的对话框中自行确定是否需要修改命名。坏导是指在数据采集时,由于各种原因(如,电极本身问题或阻抗不好等)导致数据记录有问题,但是在后期又特别想要该通道的数据,那么就可以利用插值的方法进行——利用该导联周边的几个电极点的均值作为该导的数据。上图的图是通过IClabel的工具箱进行自动判断的,可以帮助自动识别出哪些是Eye的成分。

fdgdf5535的博客 6409

记录一次linux服务器被挖矿的解决

闲来登录了一下腾讯云控制台,发现资源监控面板服务器的cpu利用率一直100%以上,甚至达到了130% 反常必有妖,毕竟我服务器除了挂了个docker几乎是没开其他应用的,一定有异常程序在作怪。 进入服务器,输入 top -c 发现有一个程序就占用100%以上的cpu,后面对应的command是: /tmp/kdevtmpfsi 百度去查了一下,发现这是一个挖矿程序,好家伙,原来服务器两个月前就被置入挖矿了。 那时候我做了什么?无非是拉取了别人的几个docker镜像,难不成docker镜像里投.

qq_32394351的博客 4072

MFC停靠窗口实战:CDockablePane从创建到控件布局的完整指南(附残影问题排查)

本文提供了MFC中CDockablePane停靠窗口的完整实战指南,涵盖从自定义窗格类创建、主框架集成、内部控件布局到高级功能定制的全过程。针对开发中常见的“残影”视觉问题,文章深入剖析了其根源,并给出了系统性的排查步骤与解决方案,帮助开发者构建稳定、专业的可停靠用户界面。

sun99的博客 620

定时清理linux 服务器日志 crontab

crontab -l查看 crontab -r查看 crontab -e 编辑 建议复制,自己写老是语法错误。 */1 * * * * flock -xn /tmp/stargate.lock -c '/usr/local/qcloud/stargate/admin/start.sh > /dev/null 2>&1 &' 0 0 * * * /usr/local/qcloud/YunJing/YDCrontab.sh > /dev/null 2&gt...

qq_35755861的博客 2383

巧妙解决网页弹窗重复出现问题

本文探讨了网页弹窗关闭后刷新重现的问题及解决方案。通过分析原生JavaScript实现的弹窗代码存在的缺陷,提出了使用jQuery改进的方法。关键点包括:利用event.preventDefault()阻止默认行为避免刷新,采用jQuery的hide("slow")方法实现优雅的关闭动画,确保关闭状态持久化。改进后的方案既解决了弹窗重复出现的问题,又提升了用户体验,为网页弹窗交互提供了更优的实现方式。文中提供了完整的HTML、CSS和JavaScript代码示例,便于开发者直接应用。

2501_90323865的博客 188

12、多端神经形态晶体管:原理、应用与算法探索

本文综述了多端神经形态晶体管的原理、应用与算法探索。从神经元MOS晶体管的发展到基于电解质栅极晶体管(EGT)的新型器件设计,系统阐述了其在低电压、多功能逻辑运算和突触行为模拟方面的优势。重点介绍了其在化学生物传感器(如多巴胺和pH检测)中的高灵敏度应用,以及在树突整合、时空总和、动态逻辑和神经元算术等树突算法中的实现。文章还总结了该类器件在神经形态计算、智能传感等领域的广阔前景,并分析了当前面临的材料工艺、理论建模与系统集成挑战,展望了未来发展方向。

delta的博客 146

Java 开发常用的 Linux 命令知识积累

写在前面虽然平时大部分工作都是和Java相关的开发,但是每天都会接触Linux系统,尤其是使用了Mac之后,每天都是工作在黑色背景的命令行环境中.自己记忆力不好,很多有用的Linux命令不能很好的记忆,现在逐渐总结一下,以便后续查看.基本操作Linux关机,重启#关机shutdown-hnow#重启shutdown-rnow查看系统,CPU信息#查看系统内核信息uname-a#查看系统内核版本cat/proc/version#查看当前用户环境变量envcat/proc/

2501_90338762的博客 1636

OpenClaw 自定义 Skill 开发完整指南(最新版)

OpenClaw 中的每个 Skill,本质是一套“能力描述 + 执行逻辑”的组合包,核心特征如下:核心载体:以文件夹为单位,文件夹内必须包含SKILL.md文件(能力描述核心);扩展文件:可选agent.py(Python 执行逻辑)、index.ts(TypeScript 执行逻辑)、(辅助文档/示例资源)等;核心优势:AI 通过阅读 SKILL.md 的自然语言描述理解技能,无需严格遵循代码接口,灵活度极高;

haolove527的专栏 2万+

linux命令日常积累

linux即时查看运行日志命令 1、cd 日志目录 2、ls 3、tail -f SystemErr.log/SystemOut.log linux修改系统时间命令 date -s 10/25/13 date -s 14:15:00

shentingtings的专栏 610

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

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

【日常积累】Linux基本命令(二)

今天继续分享一下Linux下常用的一些基础命令。

margu_168的博客 172

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

日常 Linux 命令积累

– 高亮显示日志中的内容 tail -f xxx.log | grep -C60 --color aaa – 文件目录从大到小排列 du /export/ -a |sort -rn|head -n 19

qq_1625206070の博客 249

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

个人积累linux 日常命令

linux常用命令和关闭防火墙 2. linux常用命令 Mkdir 创建 Rm -rf 删除 Chmod -R 777 权限 M...

cnkaiicg602350的博客 207

企业日常工作中常用的 Linux 操作系统命令整理

熟练掌握 Linux 常用命令,不仅能大幅提升运维效率,还能在企业生产环境中快速排查问题、优化系统性能。持续整理中…

pitt1997的博客 1646

【日常积累】Linux之screen命令使用

大家可能遇到这样的情况,当我们使用终端连接工具如xshell连接到一台服务器时,当执行一个花费时间比较长的命令时,如cp,scp或者其他时,当xshell由于某种原因突然断掉后在连上服务器时,之前执行的命令也挂掉了,会造成文件拷贝不完全。而screen 这个命令就可以帮助大家解决这个烦恼。

margu_168的博客 961

linux dt命令,Linux基础命令日常积累

今天又一次搞Linux生产环境搭建。这是种步骤很多,很繁琐而且又不得不做的事情。虽然做过很多次,但还是有很多步骤、命令不记得,每一次到处找资料很麻烦,于是将一些步骤记下,以便查找。登录远程MySQLmysql -h 192.168.1.100 -u root -p给MySQl非root账户分配权限给账号user1 密码为123456 的用户testDB数据库的所有表的select,insert,u...

weixin_39609822的博客 883

Linux命令日常积累

1、查看tomcat日志文件 1.查看实时日志文件 tail -f catalina.out 2.实时查看日志文件 最后n行 tail -n 200 -f catalina.out 3.退出tail命令 ctrl + C 4.翻页查看 日志文件(查看的是所有的日志文件) less catalina.out :G //回到文本末尾 p......

jattxgt的博客 326

linux基本操作命令日常积累

sudo grep -rin ‘hello world’ * 在当前文件夹下查找"hello world"字符。 cat -n 文件夹名 查看文件并有排序

真正的大师永远怀着一颗学徒的心 516

日常linux命令积累

echo $LANG linux下查看系统编码方式 cat /proc/version linux下查看系统版本 非root用户使用tcpdump 1.centos/redhat下安装tcpdump sudo yum install -y tcpdump 2.在tcpdump所在目录下执行 sudo chmod u+s tcpdump useradd te...

qq_35281738的博客 254
上一篇: 【日常积累】Linux之screen命令使用
下一篇: 【日常积累】使用frp进行内网穿透
margu_168
博客等级 码龄12年 6478粉丝 168原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

margu_168

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值