git学习

Git学习心得:从零到掌握的成长之路 通过Git的学习,我不仅掌握了一个工具,更理解了"版本控制思维"的价值——这种对工作过程进行系统性记录与管理的思维方式,完全可以迁移到论文写作、实验报告等学术场景。而AI工具的辅助,则像拥有了一位不知疲倦的导师,它不会直接给我答案,但总能提供突破思维瓶颈的线索。并且在我犹豫不决时,总可以看看ai是否有好的建议,并且可以随时向它提问,找到答案。未来,我计划将Git的使用延伸到更多领域:用Git管理LaTeX论文版本,用GitHub Pages搭建技术博客,甚至用Git记录机器学习实验过程。 阅读详情

安装git

[root@localhost ~/testdir]#yum install -y git

创建仓库repository

版本库又名仓库,英文名repository,你可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改、删除,Git都能跟踪,以便任何时刻都可以追踪历史,或者在将来某个时刻可以“还原”。

先创建一个空目录
[root@localhost ~/testdir]#mkdir testdir

初始化目录,变成仓库
[root@localhost ~/testdir]#git init /root/testdir/

初始化完成后可以看到相应目录下生成.git目录。这个目录是Git来跟踪管理版本库的,没事千万不要手动修改这个目录里面的文件。
[root@localhost ~/testdir]#ls -a
.  ..  .git

把工作区文件添加到暂存区

创建一个测试文件
[root@localhost ~/testdir]#vim readme
this is a test file
control by git

查看工作区状态
[root@localhost ~/testdir]#git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	readme						#未追踪文件
nothing added to commit but untracked files present (use "git add" to track)			

添加工作区文件到暂存区
[root@localhost ~/testdir]#git add readme

[root@localhost ~/testdir]#git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)					#可以从暂存区删除文件
#
#	new file:   readme
#

从暂存区删除文件
[root@localhost ~/testdir]#git rm -f readme					#-f:删除暂存区和工作区的中的文件,彻底删除

[root@localhost ~/testdir]#git rm --cache readme				#--cache:删除暂存区的文件

提交文件

[root@localhost ~/testdir]#git commit -m "test file"				#-m后面输入的是本次提交的说明。不能少
[master (root-commit) e936f52] test file
 Committer: root <root@localhost.localdomain>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.			因为没有自己创建用户和邮箱,git使用了默认配置
You can suppress this message by setting them explicitly:				

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 2 insertions(+)
 create mode 100644 readme

创建用户
[root@localhost ~/testdir]#git config --global user.name kej				#创建用户

[root@localhost ~/testdir]#git config --global user.email kej@www.kej.com				#创建邮箱

重新提交
[root@localhost ~/testdir]#git commit --amend --reset-author -m "test file"
[master 45bac50] test file
 1 file changed, 2 insertions(+)				#提示一个文件改动(readme)。插入了两行内容(readme有两行内容)
 create mode 100644 readme

查看提交日志
[root@localhost ~/testdir]#git log
commit 45bac5002fc85d77e8eceda34781805c0cb09798					
Author: kej <kej@www.kej.com>
Date:   Sun Jun 2 15:35:28 2019 +0800

commit可以一次提交很多文件,所以你可以多次add不同的文件

版本回退

现在readme文件已经被追踪。修改readme
[root@localhost ~/testdir]#vim readme 
this is a test file
controled by git
the third line

查看工作区状态
[root@localhost ~/testdir]#git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   readme					#readme文件发生改变
#
no changes added to commit (use "git add" and/or "git commit -a")

查看工作区该文件与版本库中当前分支上该文件之间的差异
[root@localhost ~/testdir]#git diff readme
diff --git a/readme b/readme
index 1d206bd..11d0dbd 100644
--- a/readme
+++ b/readme
@@ -1,2 +1,3 @@
 this is a test file
 controled by git 
+the third line						#提示新增加了一行

把文件增加到暂存区
[root@localhost ~/testdir]#git add readme

提交
[root@localhost ~/testdir]#git commit -m "add third line" readme
[master 032c62c] add third line
 1 file changed, 1 insertion(+)

查看工作区状态
[root@localhost ~/testdir]#git status
# On branch master
nothing to commit, working directory clean

查看提交日志
[root@localhost ~/testdir]#git log
commit 032c62c487d1764293923d16d9477dbc113c1414				
Author: kej <kej@www.kej.com>
Date:   Sun Jun 2 15:58:33 2019 +0800

    add third line

commit 45bac5002fc85d77e8eceda34781805c0cb09798
Author: kej <kej@www.kej.com>
Date:   Sun Jun 2 15:35:28 2019 +0800

    test file

要回退到上个版本,Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本。
也就是最新提交的commit 032c62c487d1764293923d16d9477dbc113c1414。上一个版本就是HEAD^,
上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。

[root@localhost ~/testdir]#git reset --hard HEAD^						#hard|mix|soft三种回退方式;默认mix
HEAD is now at 45bac50 test file

最新版本已经看不到了
[root@localhost ~/testdir]#git log
commit 45bac5002fc85d77e8eceda34781805c0cb09798
Author: kej <kej@www.kej.com>
Date:   Sun Jun 2 15:35:28 2019 +0800

    test file

已经还原到第一个版本
[root@localhost ~/testdir]#cat readme 
this is a test file
controled by git 

此时还可以回到第二个版本,只要上面的命令行窗口还没有被关掉,找到第二个版本的commit id。commit id号
不用写全,一般前6位就行了。
每当你觉得文件修改到一定程度的时候,就可以“保存一个快照”,这个快照在Git中被称为commit。
一旦你把文件改乱了,或者误删了文件,还可以从最近的一个commit恢复,然后继续工作.

[root@localhost ~/testdir]#git reset --hard 032c62
HEAD is now at 032c62c add third line

[root@localhost ~/testdir]#cat readme 
this is a test file
controled by git 
the third line

Git提供了一个命令git reflog用来记录你的每一次命令
[root@localhost ~/testdir]#git reflog
032c62c HEAD@{0}: reset: moving to 032c62
45bac50 HEAD@{1}: reset: moving to HEAD^
032c62c HEAD@{2}: commit: add third line
45bac50 HEAD@{3}: commit (amend): test file
d764af8 HEAD@{4}: commit (amend): test file
c7cf4f9 HEAD@{5}: commit (amend): test file
e936f52 HEAD@{6}: commit (initial): test file

Git跟踪并管理的是修改,而非文件。每次修改完成后都要git add把工作区中被修改的文件放到暂存区,然后在git commit

撤销修改

丢弃工作区中的修改
git checkout -- file			#--很重要。没有--表示切换分支

丢弃暂存区中的修改
git reset HEAD <file>,然后git checkout -- file
生成一个新的文件
[root@localhost ~/testdir]#vim test
this is a test file

[root@localhost ~/testdir]#git add test 

[root@localhost ~/testdir]#git commit -m "test file"
[master 5175295] test file
 1 file changed, 1 insertion(+)
 create mode 100644 test

删除工作区中的test
[root@localhost ~/testdir]#rm -rf test 

这是工作区与版本库中文件不一样
[root@localhost ~/testdir]#git status
# On branch master
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	deleted:    test
#
no changes added to commit (use "git add" and/or "git commit -a")

现在有两个选择
确实要从版本库中删除文件
[root@localhost ~/testdir]#git rm test
rm 'test'

[root@localhost ~/testdir]#git commit -m "remove test file"
[master 0e53a68] remove test file
 1 file changed, 1 deletion(-)
 delete mode 100644 test

误删除了工作区中的文件,要从版本库中恢复
[root@localhost ~/testdir]#git checkout -- test				#git checkout其实是用版本库里的版本替换工作区的版本,无论工作区是修改还是删除,都可以“一键还原”。

添加远程库

要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git;
[root@localhost ~/testdir]#git remote add origin git@github.com:kejlinux/learngit.git					#origin:仓库名字

关联后,使用命令git push -u origin master第一次推送master分支的所有内容;

此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改;

从远程克隆到本地

要克隆一个仓库,首先必须知道仓库的地址,然后使用git clone命令克隆。

Git支持多种协议,包括https,但通过ssh支持的原生git协议速度最快。

分支管理

创建一个分支,并切换到分支
[root@localhost ~/testdir]#git checkout -b dev		#checkout -b表示创建分支并切换到分支
Switched to a new branch 'slave'

相当于
[root@localhost ~/testdir]#git branch dev			#创建新分支

[root@localhost ~/testdir]#git checkout dev			#切换分支

查看当前在哪个分支上
[root@localhost ~/testdir]#git branch
* dev					#*表示当前分支
  master
  slave

修改dev分支上的文件
[root@localhost ~/testdir]#vim test 
this is a test file
this is second line

放入暂存区然后提交
[root@localhost ~/testdir]#git add test 
[root@localhost ~/testdir]#git commit -m "branch test"
[dev ec41110] branch test
 1 file changed, 1 insertion(+)

切换到master分区上查看文件
[root@localhost ~/testdir]#git checkout master
Switched to branch 'master'

发现刚才添加的内容不见了。这是因为添加的内容在dev分支上
[root@localhost ~/testdir]#cat test 
this is a test file

把dev分支合并到master分支上
[root@localhost ~/testdir]#git merge dev
Updating 5175295..ec41110
Fast-forward				#这次合并是“快进模式”,也就是直接把master指向dev的当前提交。
 test | 1 +
 1 file changed, 1 insertion(+)

查看master分支上的test文件,发现内容和dev分支上的test一样
[root@localhost ~/testdir]#cat test 
this is a test file
this is second line

合并完成后可以删除dev分支
[root@localhost ~/testdir]#git branch -d dev
Deleted branch dev (was ec41110).

[root@localhost ~/testdir]#git branch
* master
  slave

解决合并冲突

切换到slave分支上
[root@localhost ~/testdir]#git checkout slave
Switched to branch 'slave'

[root@localhost ~/testdir]#vim test 
this is a test file
branch slave test

[root@localhost ~/testdir]#git add test 
[root@localhost ~/testdir]#git commit -m "branch slave test" test 

切换到master分支
[root@localhost ~/testdir]#git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.				#这是因为有远程仓库。目前仓库和远程仓库内容不相同。
  (use "git push" to publish your local commits)

[root@localhost ~/testdir]#vim test 
this is a test file
this is second line
this is third line

[root@localhost ~/testdir]#git add test 
[root@localhost ~/testdir]#git commit -m "third line on master" test 

合并分支
[root@localhost ~/testdir]#git merge slave
Auto-merging test
CONFLICT (content): Merge conflict in test
Automatic merge failed; fix conflicts and then commit the result.				#发现两个分支有冲突,需要解决冲突

现在查看test文件,发现git把需要更改的地方标出来了
[root@localhost ~/testdir]#cat test 
this is a test file
<<<<<<< HEAD
this is second line
this is third line

=======
branch slave test
>>>>>>> slave

修改test文件,然后提交
[root@localhost ~/testdir]#git commit -m "conflict fixed"
[master c4d798e] conflict fixed
提交完成后不需要合并了。因为修改文件的操作相当于把slave分支上的内容整合到master分支上了

如果尝试合并
[root@localhost ~/testdir]#git merge slave
Already up-to-date.				#提示已经更新过数据了

此时可以删除分支了

git stash

当正在dev分支上进行工作时,需要临时处理另一个分支slave的工作。这时dev分支上能看到dev分支上未完成的工作
[root@localhost ~/testdir]#git branch
* dev
  master
  slave

[root@localhost ~/testdir]#vim test 
this is a test file
this is second line
this is third line
branch slave test
branch on dev
branch on dev
stash test

[root@localhost ~/testdir]#git add test				#无论是否放在暂存区,在别的分区上都可以看到修改后的内容

[root@localhost ~/testdir]#git status
# On branch dev
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   test
#

[root@localhost ~/testdir]#git checkout slave
M	test
Switched to branch 'slave'

[root@localhost ~/testdir]#git status
# On branch slave
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   test
#

可以把当前分支上的工作保存起来。这样在别的分支上就看不到了
[root@localhost ~/testdir]#git branch
  dev
  master
* slave

[root@localhost ~/testdir]#vim test 
this is a test file
this is second line
this is third line
branch slave test
branch on dev
branch on dev
stash on slave

[root@localhost ~/testdir]#git stash
Saved working directory and index state WIP on slave: 98c9973 second dev
HEAD is now at 98c9973 second dev

查看保存的内容
[root@localhost ~/testdir]#git stash list
stash@{0}: WIP on slave: 98c9973 second dev

切换到别分支上,并不能看到slave分支上的改动
[root@localhost ~/testdir]#git checkout master
Switched to branch 'master'

[root@localhost ~/testdir]#git status
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

恢复保存的内容
[root@localhost ~/testdir]#git stash apply					#这样恢复不会删除保存的内容
# On branch slave
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   test
#
no changes added to commit (use "git add" and/or "git commit -a")

[root@localhost ~/testdir]#git stash list
stash@{0}: WIP on slave: 98c9973 second dev					#保存的内容还在

需要手动删除stash保存的内容
[root@localhost ~/testdir]#git stash drop stash@{0}
Dropped stash@{0} (834ad4d84d47c027e8ccd5c0729f0bac24df4900)

可以在恢复的同时把stash内容删除
[root@localhost ~/testdir]#git stash pop

可以多次stash。选择性恢复
[root@localhost ~/testdir]#git stash apply stash@{0}

多人协同

首先,可以试图用git push origin <branch-name>推送自己的修改;

如果推送失败,则因为远程分支比你的本地更新,需要先用git pull试图合并;

如果合并有冲突,则解决冲突,并在本地提交;

没有冲突或者解决掉冲突后,再用git push origin <branch-name>推送就能成功!

如果git pull提示no tracking information,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream-to <branch-name> origin/<branch-name>。

从远程克隆分支
git clone -b 分支 仓库路径
[root@localhost ~/kej/kej]#git clone -b slave  git@github.com:kejlinux/kej.git

短视频团队架构&工作流程---2025.3.30 1、负责短视频日常内容分发上线,包括视频头图、标题、简介、推荐位及部分内容元数据的日常导入、审核、上线、下线,并提供各品类短视频的内容上线计划表。(20)运营:视频推送后,实时跟进视频数据,定期统计分析数据报表,根据数据表现 找到问题,并发送给各个小组的负责人,对下一期视频内容进行调整。(4)运营:收到成片,设计视频头图、标题、简介、推荐位等,分发到各个平台,统计分析视频的数据,对各个平台的视频进行管理、用户互动等。1、负责影视、戏剧、广告、专题片等的策划、组稿选题、材料收集、内容策划。 阅读详情

相关推荐

SPSS回归分析(线性:一元(简单)和多重;非线性logistic)

SPSS线性回归分析回归分析一、线性模型(针对连续因变量,线性关系)(一)简单线性回归(一元线性回归)1、绘制散点图2、建立简单(一元)线性回归模型3、建立模型后,检查预测结果(二)多重回归分析1、绘制矩阵分布散点图(论文专用你懂的)2、建立多重回归模型point 1:自变量加入方法:逐步(步进)法3、建立模型后,检查预测结果二、非线性模型(将非线性问题转换为线性问题)1、logistic分析的回归模型1.1 建立回归模型1.2 利用回归模型进行预测 根据之前的学习,通过评价实验得到了主观数据, 通过 描述

weixin_44394352的博客 5万+

git commit --amend修补提交用法总结

Your name and email address were configured automatically  based on your username and hostname.Please check that they are accurate. You can suppress this message by setting them explicitly:   $g

whlclw的专栏 2万+

GIT一

GIT由来 Linux内核代码需要版本管理工具管理代码,2002年开始,使用的是BitMover公司的BitKeeper这个商用软件。但 是Linux社区崇尚的是自由软件相悖。 2005年,Andrew Tridgell对BitKeeper的协议进行逆向工程,BitKeeper作者决定收回无偿使用授权。磋商无果, Linus又找不到合适的版本管理工具,决定自行开发分布式版本管理工具,一个月后,Li...

tao18225563733的博客 232

从ADC校准到精准测量:避开PY32F030小信号采样的那些坑

本文深入探讨了PY32F030微控制器进行ADC小信号采样时面临的挑战与解决方案。从硬件设计、软件滤波算法到系统级校准策略,详细分析了如何避开常见陷阱,实现精准测量,特别是在25mV以下小信号场景中的应用实践。

ujm567890的博客 758

ChatGPT设置密钥后Codex免手机验证:配置顺序与身份凭证复用机制

API Key 是一种用于身份识别的凭证,其核心原理是通过预配置的密钥替代交互式登录流程。在开发工具中,密钥认证优先级通常高于会话认证,当本地存在有效密钥时,工具会直接复用该凭证,从而减少重复验证环节。这种机制的技术价值在于提升开发效率与配置一致性,尤其适用于多设备切换、CI/CD 流水线及编程辅助工具等场景。以 Codex 为例,在 ChatGPT 界面提前配置 API 密钥后,Codex 启动时可读取持久化存储的密钥,避免触发手机号验证,实现身份凭证的跨入口复用。

weixin_33940469的博客 472

mac用户提交git commit -m ‘‘后报错

键入git config --global user.email “你的 GitHub 用户名对应的 email 地址”由于苹果机用 iCloud 账户登录系统,很显然,默认提交账户被指定为 iCloud 相关账户了。键入 git config --global user.name “你的 GitHub 用户名”

fury的博客 590

OBC_开环扫频波特图拟合操作流程(结合 Simulink)

摘要: 本文详细介绍了基于Simulink的开环扫频波特图测试与拟合流程,适用于电源/控制系统(如LLC/PFC)的小信号分析。主要内容包括:1)前期准备(测试点选择、信号范围设定);2)Simulink建模方法(信号注入、数据记录);3)两种扫频方式(逐频正弦/Chirp扫频)的实现;4)MATLAB数据处理(FFT分析、传递函数拟合);5)线性分析工具使用技巧。重点强调了激励信号幅值控制、稳态数据采集及模型验证方法,并提供完整MATLAB脚本示例。该流程可有效获取系统频域特性,为控制器设计提供可靠依据。

Sumerking的博客 234

Git修改提交的用户名和Email

<br />Your name and email address were configured automatically based<br /> on your username and hostname. Please check that they are accurate.<br /> You can suppress this message by setting them explicitly:<br /><br />     git config --global user.name

走南闯北的专栏 8411

【ESP32设备通信】-两个ESP32间UART通信

在本文中,我们将使用 Arduino IDE 的 UART 硬件库在两个 ESP32 板之间执行 UART 或串行通信。 要使用 USB 端口调试和编程 ESP32,需要使用称为通用异步接收器/发送器 (UART) 通信的串行端口。 对于大多数传感器和系统,主要的通信方法被认为是 UART。 为了共享工作负载、信息和执行不同的任务,有时需要在两个 ESP32 开发板之间进行通信。

视觉与物联智能 2993

容器化部署指南——Docker/K8s环境下的OpenClaw实践(附Dockerfile)

通过本文的详细指导,你已经掌握了OpenClaw在Docker和Kubernetes环境中的容器化部署方法。从基础镜像构建到高级部署策略,从开发环境到生产环境,你现在已经具备了完整的容器化部署能力。 容器化技术为OpenClaw提供了灵活、可扩展、可移植的部署方案,能够满足不同规模和需求的应用场景。通过合理使用Docker和Kubernetes,你可以实现高效的部署管理和运维自动化。 在实际应用中,建议根据具体的业务需求选择合适的部署策略,并结合监控、日志、安全等最佳实践,确保系统的稳定性和可靠性。同时

博客 495

刘git记录

➜ Documents pbcopy < ~/.ssh/id_ed25519.pub ➜ Documents git clone git@gitlab.com:supersl/mpvue.git Cloning into 'mpvue'... The authenticity of host 'gitlab.com (35.231.145.151)' can't be establish...

u012796234的博客 374

微观交通流仿真软件:SUMO (Simulation of Urban MObility)_(1).SUMO入门与基础概念

SUMO(Simulation of Urban MObility)是一个开源的微观交通流仿真软件,用于模拟城市交通系统中的各种动态行为。SUMO不仅可以模拟车辆的行驶,还可以模拟行人、自行车、公交车等交通参与者的运动。通过SUMO,研究人员和工程师可以对交通系统进行详细建模和分析,从而优化交通规划、评估交通政策和设计智能交通系统。车辆路径规划:SUMO可以模拟车辆在路网中的路径选择,包括动态路径选择和静态路径选择。交通信号控制:支持多种交通信号控制策略,包括固定时间控制、自适应控制等。多模式交通:模拟不同

kkchenjj的博客 1181

如何学习git:git学习之路

Git熟练度 = 基础概念理解 × 实际操作次数 × 解决问题经验最重要的三点:不要急:Git是一个需要时间沉淀的技能多实践:理论再好,不如动手操作一次敢试错:Git的设计很安全,大胆尝试各种命令开始你的Git学习之旅吧!🚀记住:每个Git大师都是从第一次git init开始的。你的Git学习之路,就从今天开始!

2401_82411601的博客 934

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Git学习计划

这篇文章介绍了Git的1V1教学计划,分为理论学习(前3周)和实践操作(后2周)两大部分。理论学习包括Git基本概念、核心术语解析和配置方法;实践操作涵盖基本开发流程和分支管理。每周设定明确的学习目标、内容、方法和任务,如概念总结、思维导图绘制、实际操作记录等。计划强调通过文档阅读、视频学习和项目实践相结合的方式,系统掌握Git的版本控制功能,最终要求对所学内容进行全面复习和总结,并建议进一步学习高级功能。整体安排循序渐进,理论与实践并重。

战族狼魂的博客 802

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

Git学习+Git在IDEA中使用

打开git命令窗口右键 ->创建git信息获取Git仓库在本地初始化初始化 手动创建仓库文件夹 -> 执行 git init从远程仓库克隆(常用) git clone 远程仓库地址。

梓梓心的博客 2719

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

学习Git的资料你想要的都在这里

一、背景 git 是开发中常见的版本管理工具,掌握好git可以说是现在工作的必备技能之一。 下面推荐一些好的配套网站和软件,以及个人推荐的提交规范。 二、学习资料 推荐几个非常不错的学习网站 官方图书和文档: https://git-scm.com/book/zh/v2 可以查看官方中文版的教程和下载PDF文档 https://git-scm.com/docs 菜鸟教程...

悟鸣的技术博客 3211

git 学习网站

跳转 这是个很好的学习git网站,值得拥有。

Stephen 602

Git学习的最佳教程

身为网页设计师或者网页开发者的你,可能已经听说过Git这个正快速成长的版本控制系统。它由GitHub维护;GitHub是一个开放性的、存储众人代码的网站。如果你想学习如何使用Git,请参考本文。在文章最后,我们罗列了其他Git学习资源。 1. Pro Git Pro Git是由Scott Chacon编写的免费在线图书,Scott现在是Git的开发人员。Pro Git有精彩的结构和一系列有组织

szu030606的专栏 1611

Git - 学习掌握Git的建议

为您整理了不同学习阶段和风格的 Git 优质课程资源,均来自社区广泛推荐,可放心学习。

guoqx的专栏 828

Git学习地址

Git学习地址

weixin_42631192的博客 205

git及github学习资源汇总

git及github学习资源汇总: git-book-zh-v2, git学习仿真沙盒 learn-git-branching等。

第七宇林的博客 460

git学习【完结】

​ 情况3:版本库存在最新版本的代码 xxx code,但是上一版不包含 xxx code,我们通常使用git进行版本控制的流程如下:工作区->(git add)->暂存区->(git commit)->版本库->(git push)->远程仓库,我们情况3撤销的前提是在commit之后没有进行push,撤销的目的就是不要影响远程仓库的代码。​ 因为创建,合并和删除分支非常快,所以Git鼓励你使用分支完成某个任务,合并后再删掉分支,这和直接在master分支上工作效果是一样的,但过程更安全。

qq_55317476的博客 1492

通过游戏式学习Git

简介 Learn Git Branching是一个游戏式关卡动画式学习Git的网站,之前一直想找一个以游戏式、关卡升级是的学习方法,这个就是,很好的,先上截图及连接。 image.png image.png [https://learngitbranching.js.org/?locale=zh_CN](https://learngitbranching.js.org/?loca...

web326的专栏 271

git完整学习指南

全面且新手友好的版本控制系统教程,涵盖从基础概念到高级应用的完整知识体系。

qq_48107900的博客 1874
上一篇: iptables
做人要开心
博客等级 码龄8年 4粉丝 28原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值