aiken's blog
  • home
  • archives
  • search
  • Aiken's Blog
  • home
  • posts
  • tags
  • categories
  • archives
  • about
  • search
  • linklog
Home

Posts

Markov Junior

@Reference: Jack Cui | Github-Markov Junior | Wiki Markov algorithm 第一篇文章简要介绍了一下该编程语言能实现什么效果;第二个是官方repo,其文档和代码都有很强的借鉴意义;第三个是wikipedia对马尔可夫算法的解释,在该编程语言的实现中有重要的意义。 markov algorithm 马尔可夫算法指的是字符串重写算法,其基本逻辑如下: 自顶向下依次检查规则,看是否能在符号串中找到任何在箭头左边的字符串。 如果没有找到,停止执行算法。 如果找到一个或多个,把符号串中的最左匹配的文字替换为在第一个相应规则的箭头右边的字符串。 返回步骤1并继续。(如果应用的规则是终止规则,则停止执行算法。) [1] MarkovJunior Markov Junior是一种基于概率的编程语言,通过重写和传播规则(约束)来实现随机的生成和编写。最终对画布进行重写来实现随机的生成。 ...

July 10, 2022 · 1 min · 26 words · aikenhong ·  Algorithm
#Algorithm

Wave Function Collapse

@Reference: Github-Mxgmn | zhihu 概念简介和复习 本质上该方法的底层思想就是条件概率的启发式随机生成算法。 波函数坍塌 在介绍算法之前首先需要明确几个概念,第一个就是**“波函数坍塌”(名字的来源是量子力学中的概念),参考“薛定谔的猫”,可以理解成:在一系列的不确定像素(存在多种可能)的基础之上,通过确定的规则**、相关关系,随机的将所有的像素变成确定的状态。(可以通过给定种子来启动,也可以通过随机规则来启动),实现在一定规则或者模式下的随机生成。 熵 熵作为热力学中,表示物理状态的参量,其含义在于表示物质的混乱程度(正相关)。在当前的场景下,使用信息熵(而非热熵)来衡量变量的不确定程度(完全随机,或者有限随机,或者二选一等等)。 $$ H(X) = \sum_{x\in X}p(x)log p(x) $$ 式中描述的是信息熵的计算公式,在实际应用中,可以使用任何表示状态不确定程度的度量来进行一下的计算。 算法原理-流程 动态地使可选的范围越来越小,直到最后整体都是确定的状态。而缩小范围的方法核心可以总结为(数独): 约束规则、状态传播、回溯 从最小熵的单位开始坍缩,保证最小概率的坍缩失败,从而减少大量的回溯过程,来减少计算量。 以地图生成为例: 约束规则:(选择一个熵最小的slot开始)针对于每个slot的坍缩,是在ModuleSet(可选模块集合)中随机取一个概率最高的模块,进行合成,而这个概率受我们制定的规则,周边的Slot的状态影响。 状态传播:模块确定后就将该状态和规则传递到相邻的moduleset中,删除不匹配的模块等。 回溯:当坍缩陷入矛盾(与规则相互矛盾,坍缩失效),就对状态进行回溯(Backtrack)重新进行状态搜索和回溯。 Read the input bitmap and count NxN patterns. (optional) Augment pattern data with rotations and reflections. Create an array with the dimensions of the output (called “wave” in the source). Each element of this array represents a state of an NxN region in the output. A state of an NxN region is a superposition of NxN patterns of the input with boolean coefficients (so a state of a pixel in the output is a superposition of input colors with real coefficients). False coefficient means that the corresponding pattern is forbidden, true coefficient means that the corresponding pattern is not yet forbidden. Initialize the wave in the completely unobserved state, i.e. with all the boolean coefficients being true. Repeat the following steps: Observation: Find a wave element with the minimal nonzero entropy. If there is no such elements (if all elements have zero or undefined entropy) then break the cycle (4) and go to step (5). Collapse this element into a definite state according to its coefficients and the distribution of NxN patterns in the input. Propagation: propagate information gained on the previous observation step. By now all the wave elements are either in a completely observed state (all the coefficients except one being zero) or in the contradictory state (all the coefficients being zero). In the first case return the output. In the second case finish the work without returning anything. Code 官方仓库中有诸多样例和各种代码版本的实现,可以参考并实现部分版本。 ...

July 10, 2022 · 2 min · 261 words · aikenhong ·  WFC ·  ALgorithm
#WFC #ALgorithm

Z Jumper for Linux

Star this Project in Github after u decide to use it. Download & Install Firstly, Cpy z.sh to the path u want make this script can be recognizabled by your shell like zsh, bash. shell cd ~ wget https://raw.githubusercontent.com/rupa/z/master/z.sh Secondly, add . ~/z.sh to the end of your .zshrc ,u can use following cmd also ...

May 20, 2022 · 1 min · 89 words · aikenhong ·  CLI
#CLI

设置各Editor自动添加meta信息

Hexo和Gitee一致,都是由Markdown文件为基础,构建的博客,编写Markdown本身无需多言,由于Hexo并非笔者的首选笔记管理方式,故而再其他地方构建和编写文件是常态,该Blog主要是利用其他工具来方便Hexo博文的编写(Header) 默认的是 hexo new [layout] title 可简写为 hexo n [layout] title,其中布局应该是在博客目录中定义,该命令也局限于博客的对应目录。 post(默认)、draft、page 除了默认的方法,本篇将介绍Obsidian、VsCode-like、Vim自动添加Header的方式,用以方便随时随地的编写博文。 同时为了方便已有笔记迁移,本文也编写了Python脚本,CPY后为Target Dir的版本自动添加Header,但是其中对应的Catagories最好还是手动修改一下。 Obsidian 通过template插件,按照对应主题的Header样式添加,可以去官方文档中找对应的语法和说明。从而构建自己的Template Workflow:插件市场添加Template -> 设置指定Template文件夹 -> 按照语法编写Template文件 -> 使用快捷键插入模板 由于这一块没有什么存在歧义的操作,就不赘述,唯一需要注意的是语法,简单参考一下官方的Example 即可,无需过于深入 本文使用的是Live my Life的Hexo-Theme,模板文件如下: ts --- title: <% tp.file.title %> catalog: true data: <% tp.date.now("YYYY-MM-DD HH:mm:ss") %> subtitle: lang: cn header-img: /img/header_img/lml_bg1.jpg tag: - categories: - mathjax: true sticky: 22 --- 实际上各个模块的操作思想都是一致的Snippet方案。 ...

April 13, 2022 · 3 min · 502 words · aikenhong ·  Blog ·  Obsidian
#Blog #Obsidian

Latex tesing

该文档主要目的是用于测试Latex语法对应前端的渲染能力,主要用于测试Hexo站点是否能正常渲染Latex。 Example1: 2 inline in one sentence. When $a \ne 0$ , there are two solutions to $(ax^2 + bx + c = 0)$ and they are $$ x = {-b \pm \sqrt{b^2-4ac} \over 2a}. $$ Example2: Matrix Example $$ \begin{bmatrix} 1&x&x^2\\ 1&y&y^2\\ 1&z&z^2 \end{bmatrix} \\ \begin{bmatrix} 1&x&x^2\\\\ 1&y&y^2\\\\ 1&z&z^2 \end{bmatrix} \\ vmatrix ||、Bmatrix{}、pmatrix() $$ Example3: the Conditional Formula $$ f(x)= \begin{cases} 0& \text{x=0}\\\\ 1& \text{x!=0} \end{cases} $$ Example4: Sprcial Symboy ...

April 13, 2022 · 1 min · 168 words · aikenhong ·  Latex ·  Blog
#Latex #Blog

部署和发布 Hexo 博客

该文档用以,记录自己(外行)利用Hexo建立Blog的过程,将原本用Gitbook构建的笔记转移到Hexo中,同时购买域名并部署其上。网页部署于Github Page 。以Live my Live主题为例。 腾讯云和Github Page的操作和理解在现有的一些博客中过时了,或者说存在一些问题,后续会对此进行简单的讲解。同时大部分博客都是使用NexT主题进行配置,这里采用的是Live My Life主题,该博文介绍自己的粗浅理解,也为自己后续的工作进行一定的参考。 还存在一些没有解决的问题: 对主题切换和主题配置和全局配置的的深入理解(Live my Life主题覆盖了很多默认配置) 前端代码的理解,自定义Layout,超链接,图标等 深入理解插件的应用和自定义 推送网站到baidu和google(Option)(没有计划) 之后有时间的话可以去研究一下: 关键词:Hexo_Livemylive、Github Page、腾讯云(Domain、DNS、SSL) Environment 需要准备的环境如下:本地Node(NPM),Page部署Git(SSH),可在Windows,Linux,WSL2中部署均可,但需要注意的是,如果在WSL2中进行部署,生成速度与部署速度会明显慢于宿主机。 首先安装NodeJS、NPM、Git并验证是否成功安装,根据Linux和Windows不同环境进行安装,可以去官网了解相关的安装步骤,或者参考Gitee和Github的两篇博文。 为了更好的编写笔记,最好配置一个图床,图床的配置可以使用Github、Gitee或者腾讯云的COS服务,相关的配置可以参考LInk sh git version node -v npm -v 安装Hexo sh npm install -g hexo-cli # 查看Hexo的版本 hexo -v Initialize Blog 对博客目录初始化:hexo init blog,blog为空的话初始化当前文件夹,初始化后基本结构如下: ...

April 12, 2022 · 4 min · 754 words · aikenhong ·  Blog ·  Hexo
#Blog #Hexo

Vim 01 Recorder

Chose Your Dotfile to start the vim shell vim -u {path to your .vimrc} Recorder of Vim This Chapter mainly introduces the Recorder in vim,Which is used to do some repeated operations.This function is also called a macro. for more information try :help recording ...

April 7, 2022 · 2 min · 376 words · aikenhong ·  Vim
#Vim

使用 PicGo 设置图床

@Aiken 2020 first write,2021 modify Mainly using picgo-core(command line) to setting picbed,and we can update the setting method Github 使用PicGo-Core(command line)设置github图床,自动转义url 插入自动复制图片,使用git上传github 基本部署 在偏好设置中的图像,进行如下设置👇: 下载或更新PicGo-Cord(command line) 接着去Github中建立一个Repo:UserName/RepoName,用以存放图片(Public),简单的用readme初始建立即可。 在Github的setting - developer setting-personal access tokens中新建token,指定简单的repo权限,并记录个人的token(只显示一次) Attention: 忘记记录的话,在token中也是通过update token(好像是这个名,获取新的值的) 用Typora打开配置文件设置,或者使用命令行进行配置 json { "picBed": { "github": { "repo": "UserName/RepoName", "token": "your github token here", "path": "img/", "customUrl": "https://raw.githubusercontent.com/UserName/RepoName/master", "branch": "master" }, "current": "github", "uploader": "github" }, "picgoPlugins": {} } 点击验证图片上传选项,进行测试,成功即可 存在问题 用Github做图床的话,上传不是十分的稳定(可能需要依赖科学上网技术。请八仙过海,各显神通)。可以用其他的服务器作图床,大体过程应该也差不多,后续个人有更换的话在进行补充。 ...

March 27, 2022 · 1 min · 200 words · aikenhong ·  Blog
#Blog

Fine Tuning

@Langs: python, torch @reference: d2l-pytorch,transfer_torch This Note focus on the code part. 模型微调和模型预训练,在Pytorch中的使用方式对比汇总。 How to Design the Fine Tune 这一部分主要集中于我们对于微调任务的拆解,有几种不同的预训练和微调的方式,在不同的情景下,对应的参数应该怎么设置和调整是问题的重点。 基于这种Transfer的策略,我们能够学习到一个更通用,泛化能力更强,有助于识别边缘,色彩,等等有助于下游任务的通用特征提取。 在Transfer任务中,有几种不同的调整方式: 固定Bakcbone,只训练Classifier 同步微调网络 区分学习率,微调Backbone,训练Classifirer 为了实现这几种不同的Transfer方式,需要用到以下的几种方式:梯度截断,lr区分设置等。 Code Part 不同lr设置 微调Backbone,训练Classifier作为最经典的Transfer设定,在Code上也较为复杂,所以我们首先举个这种例子。 相关的文档可以参考:torch.optim python # get dataset train_img = torchvision.datasets.ImageFolder(os.path.join(data_dir, 'train')) # get new model pretrained_new = model.expand_dim(dim=out_dim,re_init=True) # pre train it 定义一个用于微调的函数 # pytorch可以通过字典的形式来区分对设置lr def train_fine_tuning(net, learning_rate, batch_size=128, num_epoch=5, diff_lr=True): # set dataloader train_iter = torch.utils.Dataloader(train_img, batch_size=batch_size, shuffle=True) test_iter = ... # set loss loss = nn.CrossEntropyLoss(reduction='none') # set diff lr for diff part of it if diff_lr: params_1x = [param for name, param in net.name_parameters() if name not in ["fc.weight", "fc.bias"]] trainer = torch.optim.SGD([{'params': params_1x}, {'params': net.fc.parameters(), 'lr': learning_rate *10}], lr=learning_rate, weight_decay=0.001 ) else: trainer = torch.optim.SGD(net.parameters(), lr=learning_rate, weight_decay=0.001) 同时不用担心,scheduler可以将我们的两组lr同时进行更新,可以基于下面的代码进行测试 ...

February 8, 2022 · 2 min · 235 words · aikenhong ·  Fine-Tune ·  ML-Training
#Fine-Tune #ML-Training

Git 01 入门与常用操作

参考文献:稀土掘金 | ProGit2 GIT 与 SVN 的区别 SVN 是集中式版本控制系统,其所有的版本管理都是集中在某个中央服务器,因此,在干活的时候,首先都需要从中央服务器中获取最新的版本,修改后将版本推送到中央服务器,因此大多数场景下需要进行联网使用。可能会更依托于相应的图形化客户端来进行同步和版本管理,便于管理美术资源等等。 GIT 是分布式版本管理系统,每个人的电脑就是一个完整的版本库,可以进行独立的版本管理,多人协作可能依托于 github 之类的中继节点,将修改同步给对方,解决冲突。 Init 初始化 包含 ssh 的详细指令在 ssh 的文档中,这边只介绍设置完这一系列操作之后的 git 初始化,主要是初始化 ssh,并将私钥放到 github 或者 gitee 的账户中。 shell git config --global user.name "YourName" git config --global user.email "YourEmailAdress" # 查看相关的配置信息 git config --list # 设置CRLF和LF的相关转换 第一条在提交的时候自动抓换位LF,迁出转换为CRLF # 第二条拒绝混合换行符的提交 git config --global core.autocrlf true git config --global core.safecrlf true Github 设置 官方文档介绍的一些权限错误的地址:< https://docs.github.com/en/github/authenticating-to-github/error-permission-denied-publickey> ...

February 1, 2022 · 6 min · 1082 words · aikenhong ·  Git
#Git
<< « Prev 9/17 Next 11/17 » >>
© 2025 aiken's blog Licensed under CC BY-NC 4.0 · Powered by Hugo & PaperMod Visitors: Views: