群晖-python运行状态提醒
runcat-pyqt5-win:在windows任务栏养猫(2)
keras调用tensorborad时报错 AttributeError 'Model' object has no attribute '_get_distribution_strategy'
keras调用tensorborad时报错:AttributeError: 'Model' object has no attribute '_get_distribution_strategy'
软件版本:
- python: 3.7.4
 - keras: 2.3.1
 - tensorboard: 2.1.0
 - tensorflow: 2.1.0
 
解决办法A:
- 参考tensorflow的 pull #34870 : “Use _get_distribution_strategy only when it is available. “ https://github.com/tensorflow/tensorflow/pull/34870
 
The changes introduced in 06d8f77 are not compatible with standalone
Keras(they are compatible withtf.Keras). akeras.Modeldoes not have a_get_distribution_strategymethod, which is now assumed for theTensorboardcallback.
- 直接修改
tensorflow/python/keras/callbacks.py文件,如下图。 
数据可视化-等高线-pandas透视图-seaborn热力图-桑基图(Sankey)
matplotlib绘制等高线
ref: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.contour.html
1  | import numpy as np  | 
数据可视化-等高线-pandas透视图-seaborn热力图-桑基图(Sankey)
matplotlib绘制等高线
ref: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.contour.html
1  | import numpy as np  | 
数据可视化-等高线-pandas透视图-seaborn热力图-桑基图(Sankey)
matplotlib绘制等高线
ref: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.contour.html
1  | import numpy as np  | 
听不到
悠悠:我又听不到你说话了,我的耳朵又听不到说话了。
妈妈:怎么了?耳朵哪不舒服了?
悠悠:你不说表扬的话,我都听不到。
妈妈:[捂脸][捂脸][捂脸][捂脸]
raspberry pi 运行状态提醒
群晖python3配置
pip3 安装、配置
群晖默认不支持 apt-get 之类的命令,使用 wget 下载 get-pip.py 安装 pip。
1  | wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py'  | 
安装之后提示 pip3 的安装目录(一般是 /homes/USERNAME/.local/bin)不在系统的环境变量里。
每次要先跳到安装目录里。
1  | cd .local/bin  | 
深度学习调参-keras,tensorflow设置随机种子,保证结果可复现
keras,tensorflow设置随机种子,保证结果可复现
ref: https://tensorflow.google.cn/api_docs/python/tf/random/set_seed
1  | np.random.seed(42)  | 
Hexo 使用 Github Actions 自动更新
准备
- 需要两个 github 仓库:
- 一个用于发布页面: XXXXXX.github.io
 - 一个用于放源码: hexo-source (可设为隐私仓库)
 
 
1. 创建 hexo-source 仓库
- 在hexo的根目录下( ~/hexo)运行:
 
1  | cd hexo  | 
2. Github Actions 设置
- 运行 ssh-keygen 生成一对密钥。
 
1  | ssh-keygen  | 
- 打开 XXXXXX.github.io 仓库设置,在 
Deploye keys选项中,添加公钥~/.ssh/id_rsa.pub的内容。 - 打开 hexo-source 仓库设置,在 
Secrets选项中,新建 repo secret: 名称设为GITHUB_ACTION, 内容为~/.ssh/id_rsa的内容。 
latex插入eps图片
latex 环境安装与配置
在 win10 下尝试过的 latex 环境有以下三种:
- texlive + texstudio
 - ctex (集成 miktex + winedt, 以及中文支持)
 - miktex + texstudio / (vscode + latex workshop)
 
1. texlive + texstudio
这个是最常用的配置方法,建议新手从这个开始使用。
优点:基本适用于所有的场景(中文除外),一劳永逸;
缺点:默认不支持中文,安装包巨大。
texlive 安装: 可以在线安装,也可以离线安装(推荐,安装包
3.2G),安装后6G的空间。texstudio 安装:下载安装包(~89M),正常的安装方法即可。
- 官网下载: http://texstudio.sourceforge.net/
 - Scoop 安装: 
scoop install texstudio 
texstudio 默认的配置就基本够用,不要乱改。
- 中文,字体,字号
 - 高级配置:行号、空白等
 
ps: texstudio的提示、警告、错误信息非常明确,出现问题先看提示。
数据处理-scipy中值滤波、pandas重采样
1. scipy中值滤波
使用scipy中的signal.medfilt对数组进行中值滤波。
方法: scipy.signal.medfilt
- 滤波器的kernel_size必须是奇数
 - 输出数组的size与输入的数组一致
 
1  | import scipy.signal as signal  | 
signal.medfilt还可以对矩阵(图像)进行滤波处理,以消除噪音。
ref: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.medfilt.html
深度学习调参-自动化运行多组超参数
1. 创建一个神经网络模型
比如用cnn在mnist数据集上训练,关于模型建立和训练的代码这里不写了。。。
在程序开头加入超参数的定义:建议至少包括参数名称、类型、和初始值。
1  | #########################  | 
深度学习调参-超参数排列组合
首先定义超参数的名称和取值范围,
然后调用itertools.product,可以生成所有超参数的排列组合。
1  | import itertools  | 
输出:
==== we have 54 cases in total =========
 *** 1 / 54  *********
python mnist_cnn.py --layer_n=1 --activition=tanh --seed=11
 *** 2 / 54  *********
python mnist_cnn.py --layer_n=1 --activition=tanh --seed=17
 *** 3 / 54  *********
python mnist_cnn.py --layer_n=1 --activition=tanh --seed=19
 *** 4 / 54  *********
python mnist_cnn.py --layer_n=1 --activition=sigmod --seed=11
 *** 5 / 54  *********
python mnist_cnn.py --layer_n=1 --activition=sigmod --seed=17
 *** 6 / 54  *********
 
 ...
 *** 53 / 54  *********
python mnist_cnn.py --layer_n=6 --activition=relu --seed=17
 *** 54 / 54  *********
python mnist_cnn.py --layer_n=6 --activition=relu --seed=19
      
    