准备

  • LED灯,3mm无边LED灯 暖白色
  • 背光固件:DC87出厂默认没有背光,需要刷固件,关键词搜”信必成m20双模”

焊灯

DC87的灯位最上面一排没有预留焊锡,其他的预留了焊锡。

可以先加热后直接把led戳进去;或者用吸锡器先把预留的焊锡全部吸掉。

我这里直接加热后戳进去的,个别的需要补一点焊锡防止虚焊。

阅读全文 »

鼠标一直用的地狱狂蛇 Abyssus。

最早是2010款的磨砂版,当时还是蓝色的led灯,3500DPI,底部有两个调节开关。
用了三年多,左键双击了。当时还觉得挺可惜的。

后面买了两个2014款的,一个公司用,一个家用。
这款led灯被改成了绿色,1800DPI,调节开关也被减配了。
用了没多久,家里的鼠标中键就不是很灵了;最近公司的也出现了这个现象。

阅读全文 »

投稿模板要用 els-cas-templates, ctex编译不过去,错误如下:

error: Environment graphicalabstract undefined

原因不用想,肯定是ctex内置的latex(miktex)版本太老了。

1. 试着更新一下miktex。

miktex 官网: https://miktex.org/

最新版是: MiKTeX 20.6 (6/28/2020), 大概230M。

https://miktex.org/download/ctan/systems/win32/miktex/setup/windows-x64/basic-miktex-20.6.29-x64.exe

(最近miktex的版本号也改成了 年.月 的形式,之前是 2.9.x 的格式。)

  • 先把ctex安装目录内的 miktex 文件夹重命名成 miktex-old (保险起见,后面没问题再删)。
  • 安装MiKTeX 20.6到这个ctex默认的目录下。
  • 安装完,打开winedit,应该是能自动找到新的latex的;不行的话,检查一下路径。
阅读全文 »

Pycharm的文本对比功能强大,比VS Code好用的多。

  • 在工程里的文件树上,选中两个文件,然后Ctrl+D(或者右键->Compare)即可。
  • 但是要比较工程以外的文件,或者没打开Pycharm的时候想对比文件时,比较麻烦。毕竟Pycharm又不能秒开。

这里尝试下更方便的用法。

预期功能: 选中两个文件,然后右键“diff with pycharm”。

0. Pycharm CLI

在官网查到Pycharm支持命令行了,支持打开、对比、合并等一些命令。
https://www.jetbrains.com/help/pycharm/working-with-the-ide-features-from-command-line.html

基本用法如下:

1
2
3
4
5
pycharm.bat <file / folder>       # 打开文件或目录
pycharm.bat diff <file> <file> # 对比两个文件
...
...

我们这里只用到 diff 命令。

方法1. 改注册表添加到右键菜单(失败)

先尝试修改注册表,把diff命令添加到右键菜单。

但是注册表里好像不支持把两个或多个文件作为参数传入。

下面的设置,只能分别打开两个pycharm程序,实现不了打开一个pycharm,传入两个文件名

1
2
3
4
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\*\shell\diff with pycharm\command]
@="C:\\Users\\shenbo\\scoop\\apps\\PyCharm-Professional\\current\\IDE\\bin\\pycharm.bat diff \"%1\""

试了把 %1 改成 %*, %V, 都不行。。。

阅读全文 »

1.安装

可在应用商店安装,也可以scoop安装。

1
scoop install windows-terminal

2. 配置文件

在设置里直接打开的是个人配置:setting.json

按下alt再打开是默认配置文件:default.json

直接默认文件的内容全部拷贝到个人配置里。

简单的改一下powershell的设置,主题、字体、启动目录。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"profiles":
[
{
"guid": "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}",
"name": "Windows PowerShell",
"commandline": "%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"icon": "ms-appx:///ProfileIcons/{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}.png",
"colorScheme": "Campbell",
"antialiasingMode": "grayscale",
"closeOnExit": "graceful",
"cursorShape": "bar",
"fontFace": "JetBrains Mono",
"fontSize": 11,
"hidden": false,
"historySize": 9001,
"padding": "8, 8, 8, 8",
"snapOnInput": true,
"altGrAliasing": true,
"startingDirectory": "%USERPROFILE%",
"useAcrylic": false
},
]

阅读全文 »

1. Jetbrains Mono 字体

Jetbrains 推出了一款新字体: Jetbrains Mono,还不错。

  • 支持连字
  • 不含中文字符
  • 含 powerline 字符

官网的更新比Github慢

2. VSCode 设置

编辑器和终端都可以设置,打开 setting.json, 加入:

1
2
3
4
5
6
{
"editor.fontFamily": "'JetBrains Mono', 'Courier New', monospace",
"editor.fontLigatures": true,

"terminal.integrated.fontFamily": "JetBrains Mono",
}

默认的0是中间带点的0,要改为带斜杆的0,改成下面的:

1
2
3
4
{
"editor.fontLigatures": "'calt' off, 'zero' on", // 关闭连字
"editor.fontLigatures": "'calt' on, 'zero' on", // 开启连字
}

3. Jetbrains Mono Nerd-Fonts 版

https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/JetBrainsMono/

1
2
3
4
5
aria2c https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Regular/complete/JetBrains%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible%20Regular.ttf

aria2c https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Italic/complete/JetBrains%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible%20Italic.ttf

aria2c https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Bold/complete/JetBrains%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible%20Bold.ttf
1
2
3
4
5
aria2c https://ghproxy.net/https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Regular/complete/JetBrains%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible%20Regular.ttf

aria2c https://ghproxy.net/https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Italic/complete/JetBrains%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible%20Italic.ttf

aria2c https://ghproxy.net/https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/JetBrainsMono/Ligatures/Bold/complete/JetBrains%20Mono%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible%20Bold.ttf

VS Code 编辑器和终端都可以设置,打开 setting.json, 加入:

1
2
3
{
"editor.fontFamily": "'JetBrainsMono Nerd Font Mono', 'Courier New', monospace",
}

1. 硬件

  • 1.1 步进电机

一般4线制:A+、A-、B+、B-

  • 1.2 驱动器

驱动器一般有总线控制和脉冲控制两种方法,这里用的脉冲控制。

端子名称及说明如下(仅参考,以说明书为准):

名称 符号 备注
24V电源 DC+、DC- 接DC24V电源
电机接口 A+、A-、B+、B- 接电机
总线接口 CANH、CANL
脉冲接口 DIR、PUL、GND、EN
  • 1.3 控制器
    这里用YF-19控制器,实验用。
阅读全文 »

(书房里)

妈妈:我睡在这个床上的时候,老是害怕空调会掉下来。

悠悠:你是不是还害怕天花板会掉下来。。。

1. zsh 安装

ref: https://synocommunity.com/

先从套件中心中安装zsh 。

  • 登录DSM,找到 套件中心设置, 将 信任层级 设为 Synology Inc. 和信任的发行者.

  • 套件来源 选项卡中, 增加一项:

  • 返回 套件中心, 左侧可以看到 社群 选项卡, 打开后可以看到里面有 Z shell (with modules), 安装套件.

1
2
3
4
5
6
7
8
# 显示当前 shell 类型
echo $SHELL

# 显示可使用的 shell
cat /etc/shells

# 显示 zsh 安装路径
which zsh

2. oh-my-zsh 安装

ref: https://ohmyz.sh/
ref: https://gitee.com/mirrors/oh-my-zsh.git

  • 需要先安装 git. (在套件中心里有)

  • 用 wget 安装。

    1
    2
    3
    4
    $ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

    # gitee 镜像
    $ sh -c "$(wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh -O -)"
  • 简单配置一下,打开配置文件 nano ~/.zshrc

    1
    2
    3
    4
    5
    # 主题
    ZSH_THEME="ys"

    # 插件
    plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
  • 下载插件

    1
    2
    3
    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

    git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  • 加载配置文件, source ~/.zshrc

阅读全文 »

1. 硬件

  • 1.1 直流电机

一般是8线制:

名称 符号 备注
电机电源 U、V、W
霍尔开关电源 REF+、REF- DC5V, 接控制器或5V电源
霍尔开关信号 HU、HV、HW
  • 1.2 控制器

控制器种类太多,部分端子名称及说明如下(仅参考,以说明书为准):

名称 符号 备注
24V电源 DC+、DC- 接DC24V电源
电机电源 U、V、W
霍尔开关电源 5V+, GND
霍尔开关信号 HU、HV、HW
使能 RUN / EN 低电平启动,断开停止
正、反转 REV / FR 低电平反转,断开正转
调速 SPD / SV 0-5V电压调速
刹车 BK 高电平刹车
转速输出(脉冲) PLS 5V脉冲信号
转速输出(开漏) PG 需在5V与PG间加2K-10K上拉电阻
阅读全文 »

0. 官方文档

Next 介绍了两种方案: mathjax / katex 。

https://theme-next.js.org/docs/third-party-services/math-equations

这里用的是 mathjax。

1. mathjax配置

1.1 正文 Front-matter

1
2
3
4
5
---
title: Hexo中的数学公式
date: 2020-04-25 01:46:39
mathjax: true
---

1.2 Next主题配置

1
2
3
4
5
6
7
8
9
10
11
math:
# Default (true) will load mathjax / katex script on demand.
# That is it only render those page which has `mathjax: true` in Front-matter.
# If you set it to false, it will load mathjax / katex srcipt EVERY PAGE.
per_page: true

# hexo-renderer-pandoc (or hexo-renderer-kramed) required for full MathJax support.
mathjax:
enable: true
# See: https://mhchem.github.io/MathJax-mhchem/
mhchem: false

1.3 安装插件(貌似可以不装,默认的也能用)

先卸载 hexo-renderer-marked, 再安装 hexo-renderer-pandoc

1
2
npm un hexo-renderer-marked
npm i hexo-renderer-pandoc
阅读全文 »

回归问题常用的评估指标

回归问题常用的评估指标包括:MAE, MAPE, MSE, RMSE, R2_Score等。

这些评价指标基本都在 sklearn 包中都封装好了,可直接调用。

安装 sklearn, 完整的名字是 scikit-learn

1
2
pip install -U scikit-learn
# 现在最新版是 V0.22.2.post1
metric formula method
MAE $\frac{1}{n} \sum_{i=1}^n \vert y_i - \hat{y}_i \vert$ sklearn.metrics.mean_absolute_error
MAPE $\frac{1}{n} \sum_{i=1}^n \frac{\vert y_i - \hat{y}_i \vert }{\vert y_i \vert}$ sklearn.metrics.mean_absolute_percentage_error
MSE $\frac{1}{n} \sum_{i=1}^n (y_i - \hat{y}_i)^2$ sklearn.metrics.mean_squared_error
RMSE $\sqrt{\frac{1}{n} \sum_{i=1}^n (y_i - \hat{y}_i)^2}$ sklearn.metrics.mean_squared_error
R2 Score $1 - \dfrac{\sum_{i=1}^n (y_i - \hat{y}_i)^2} {\sum_{i=1}^n (y_i - \bar{y})^2}$ sklearn.metrics.r2_score

注:

  • MAPE 在V0.22.2中还不能直接调用,预计会在V0.23中发布;
  • RMSE 可以调用 mean_squared_error 方法实现, 设置 squared=False 即可;
    • rmse_score = mean_squared_error(y_test, y_pred, squared=False)
阅读全文 »

1. 桑基图(Sankey)介绍

sankey图可用于数据从一系列节点到另一系列节点流入流出的可视化。

主要有两个基本概念:

  • 节点 (nodes)
  • 连接 (links): 源节点至目标节点之间的关系,每个连接包括三个元素:
    • source: 源节点
    • target: 目标节点
    • value: 数据

ref: https://developers.google.com/chart/interactive/docs/gallery/sankey

2. 绘制桑基图(使用pyecharts)

常用的绘图库 matplotlib, seaborn 好像不支持桑基图, 这里使用了 pyecharts 。

这里 https://gallery.pyecharts.org/#/Sankey/sankey_base 有几个例子。

阅读全文 »

1. 安装虚拟屏幕

我的树莓派系统是 buster lite 版,没有界面,所以先要安装 xvfb

1
sudo apt install xvfb

2. 安装 firefox

1
2
3
4
sudo apt install firefox-esr

firefox-esr -v # 安装完可以检测一下版本
# Mozilla Firefox 68.7.0esr
阅读全文 »

pytorch调用inception-v3报错:

1
2
3
4
5
6
7
error:
train_model(model, criterion, optimizer, scheduler, num_epochs)
37 outputs = model(inputs)
---> 38 _, preds = torch.max(outputs, 1)
39 loss = criterion(outputs, labels)
TypeError: max() received an invalid combination of arguments - got (InceptionOutputs, int), but expected one of: ...

软件版本:

  • python: 3.7.7
  • pytorch: 1.4.0
  • torchvision: 0.5.0

解决办法:

tensorflow gpu 报错:

1
2
3
4
5
... tensorflow/stream_executor/cuda/cuda_blas.cc:238] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
...
... tensorflow/stream_executor/cuda/cuda_dnn.cc:329] Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED
...
... Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.

软件版本:

  • python: 3.7.7
  • keras: 2.3.1
  • tensorboard: 2.1.0
  • tensorflow: 2.1.0

显卡版本:

  • gpu: RTX 2070
  • cuda: 10.1
  • cudnn: 7.8

解决办法:

You may try limiting your gpu memory usage with set_memory_growth option.
See https://www.tensorflow.org/guide/gpu#limiting_gpu_memory_growth
Put the following snippet on top of your code and execute again

1
2
3
import tensorflow as tf
gpus= tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(gpus[0], True)

妈妈:悠悠,你长大了有什么梦想?想当医生,老师,加油站工作人员,开挖掘机,还是科学家?

悠悠:我想开挖掘机,妈妈,你小时候的梦想是什么?

妈妈:是当一名教师。

悠悠: 爸爸,你小时候的梦想是什么呢 ?

爸爸: 我想当一名修理工,修摩托车,修汽车。。。

悠悠:那你修了吗 ?

爸爸:没有,我没有实现,我现在也不会修车 。

悠悠:我长大了可以帮你实现你的理想,你们也可以帮我实现我的理想 。

爸爸:你的理想是什么?

悠悠:我的理想是开挖掘机呀。。。妈妈只想当一个老师。

爸爸:当老师也很好啊。

悠悠:当老师可以教学生。

爸爸:额… 那你想开挖掘机去挖什么呢?

悠悠:就是把路哪里不平了,就把他挖一下。

爸爸:哦,我知道了,就是把所有路上不平的地方都给他挖平,让别人可以走!

悠悠:对呀~

爸爸:哇,那你这个理想很伟大呀!

悠悠:对呀~。。。你都不知道你要修什么车。

爸爸:。。。

1. 安装 oh-my-posh, posh-git

可以用scoop安装:

1
2
# scoop bucket add extras
scoop install oh-my-posh

新建、修改配置文件,运行:

1
2
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
code $PROFILE

加入以下内容:

1
2
3
4
5
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
# 如果PowerShell设置里找不到字体,加上下面这一行
# chcp 65001

ref: https://github.com/JanDeDobbeleer/oh-my-posh/

2. 设置字体

然后把字体设置为更纱黑体,就基本看起来比较舒服了。

也可以用其他的字体,去这里找: https://github.com/ryanoasis/nerd-fonts

但是我并不想用这些字体

阅读全文 »

1. 安装 psreadline

ref: https://github.com/PowerShell/PSReadLine

1.1 从 PowerShellGallery 中安装。

依次安装PowerShellGet, PSReadLine

1
2
Install-Module -Name PowerShellGet -Force
Install-Module PSReadLine

安装完就有历史纪录了,关闭后可以保存历史记录。

1.2 查看已安装的模块

1
Get-InstalledModule

2. 智能提示

2.1 将PSReadLine 升级至V2.1(测试版)

安装完之后没有智能提示,按tab键跳出来的命令都很奇怪。(我安的是稳定版,V2.0.2)

发现测试版就加入了类似 fish 的智能提示,版本是V2.1.0-beta2。

ref: https://github.com/PowerShell/PSReadLine/pull/1496

更新一下PSReadLine,用命令行窗口升级:

1
2
# cmd
powershell -noprofile -command "Install-Module PSReadLine -Force -SkipPublisherCheck -AllowPrerelease"

或:

1
Update-Module PSReadLine -Force

然后将 PredictionSourceSource 设为 History

1
2
# powershell
Set-PSReadLineOption -PredictionSource History # 默认是 None

2.2 查看 PSReadLine 的设置

1
Get-PSReadLineOption

2.3 修改配置文件

但是似乎窗口关闭后,就失效了。

需要把设置这一行加到配置文件里就好了,新建、修改配置文件,运行:

1
2
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
code $PROFILE

就能打开配置文件。

在配置里加入这一句。

1
Set-PSReadLineOption -PredictionSource History  # 默认是 None

Done!

1. 安装 PowerShell 5.0 以上版本

2. 用concfg配置主题

ref: https://github.com/lukesampson/concfg

1
2
3
4
5
6
7
8
9
10
11
scoop install concfg

# 设置主题
# concfg import cmd-default # 暗色调
concfg import google-light # 浅色调

# 列出所有预设主题
concfg presets

# 恢复原始设置
concfg clean

3. 安装字体

阅读全文 »