Tensorflow
Notes about using Tensorflow
Quick notes
trainable: If True
, the default, also adds the variable to the graph collection GraphKeys.TRAINABLE_VARIABLES
. This collection is used as the default list of variables to use by the Optimizer
classes.
Tensorflow gpu auto growth
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
Reset default graph
tf.reset_default_graph()
Tensorboard
with tf.Session(config=config) as sess:
# ...
writer = tf.summary.FileWriter('./graphs/test', sess.graph)
writer.flush()
writer.close()
Startup tensorboard:
Keras
Notes about Keras.
- Keras version:
2.0.8
.
Frequently used snippets
Problems encountered
2017-12-04 · Get variable’s value in middle layer
Problem description: I want to get the value of a variable in the model.
Reference: How can I get hidden layer representation of the given data? #41
The simplest way is using the same code of the original model, and
# replace the output with the variable you want
# code ...
new_model.set_weights(trained_model.get_weights())
new_model.predict(input_data, batch_size=32)
Note the batch_size
is import for large amount of samples. The K.function()
mentioned in the issue #41 raised OOM exception
. Of course you can split data into batches by yourself and use the K.function()
method, but the method showed above is more convinient for me in my case.
Color
We live in a colorful world, but color isn’t that simple. This article will introduce some knowledges of color, including:
- How does human recognize colors
- Different color space
Adobe
In this article, you will see:
- Shortcuts of Photoshop and Illustrator
- Some tricks
- Highly recommended materials for learning
CSS
Quick notes
Safe fonts
A complete collection of web safe CSS font stacks.
Add two common fonts for Chinese characters: PingFang SC
, Microsoft YaHei
.
$font-family-serif: Palatino, Georgia, "Times New Roman", "PingFang SC", "Microsoft YaHei", serif !default;
$font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !default;
Difference between Serif and Sans Serif
See this great inforgraphic: The Difference Between Serif And Sans-Serif Explained In One Infographic
JavaScript
This is a note about JavaScript.
Quick notes
Ignore SSL issue
Error: (node:99469) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: Hostname/IP doesn’t match certificate’s altnames: “IP: <ip> is not in the cert’s list: “
https://github.com/axios/axios/issues/535
https = require('https')
axios = require('axios')
// At instance level
const instance = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
});
instance.get('https://something.com/foo');
// At request level
const agent = new https.Agent({
rejectUnauthorized: false
});
axios.get('https://something.com/foo', { httpsAgent: agent });
酒
黄酒
黄酒是用稻谷酿造的,稻谷本不含糖,必须要将淀粉转化为糖,然后再把糖发酵成酒精,而帮助稻谷糖化并发酵的就是曲。
酿造工艺
- 浸米
- 蒸米
- 落缸,根据不同的风格,用不同方式投入米、麦曲、酒药、水等各种原料,等待酒发酵。
- 开粑,发酵过程中温度会提升,酵母就不再作用了,必须由酿酒师把酒醪表面的漂浮物铲下去,从而起到降温的作用。开耙师傅是匠人,不同的时间点开耙都会酿出风格截然不同的酒。
- 装坛
- 压榨,从小坛中倒出黄酒,过滤、压榨、澄清、杀菌,每一个步骤都有利于增加黄酒的保质期,但是都会损失一部分风味。
- 装瓶
Bootstrap
Quick notes
.d-none
, hide elements.d-{sm,md,lg,xl}-none
- Tips: use
d-none
first, and specify screen display mode to cover it.
container-fluid
, full width container
Responsive breakpoints
Github issue: Bootstrap default breakpoints
Viewport dimensions.
xs
, extra small- \( xs \le 575.98px \)
sm
, small- \( 576px \le sm \le 767.98px \)
md
, medium- \( 768px \le md \le 991.98px \)
lg
, large- \( 992px \le lg \le 1199.98px \)
xl
, extra large- \( xl \ge 1200px \)
Take control over the viewport:
<meta name="viewport" content="width=device-width, initial-scale=1.0">