0%

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os.path as osp
import sys


def add_path(path):
if path not in sys.path:
sys.path.insert(0, path)


this_dir = osp.dirname(__file__)

lib_path = osp.join(this_dir, '..', 'lib')
add_path(lib_path)

键值对

  1. “:”和键值之间必须有至少一个空格。
  2. 使用两个空格作为一级缩进是 YAML 的约定,不能使用制表符(Tab)来代替,务必注意这一点。

列表

1
2
3
4
5
-  value1 

- value2

- value3

或者

1
2
- [value1, value2, value3] 

注意第二种写法前面的“-”必不可少,并且要跟随至少一个空格。

双引号和单引号, 推荐使用单引号

使用双引号括起来的字符串中的 \n 符号会被解析为换行符,而单引号中的 \n 符号则仍然视为两个普通字符。

1
2
import scipy.io as matio
data = matio.loadmat("a.mat")

1
2
torch.manual_seed(1917)
torch.cuda.manual_seed(1997)

包括左右端点。。。

如果人们选择图像中的连续范围作为池化区域,并且只是池化相同(重复)的隐藏单元产生的特征,那么,这些池化单元就具有平移不变性 (translation invariant)。

这就意味着即使图像经历了一个小的平移之后,依然会产生相同的 (池化的) 特征。

在很多任务中 (例如物体检测、声音识别),我们都更希望得到具有平移不变性的特征,因为即使图像经过了平移,样例(图像)的标记仍然保持不变。

例如,如果你处理一个MNIST数据集的数字,把它向左侧或右侧平移,那么不论最终的位置在哪里,你都会期望你的分类器仍然能够精确地将其分类为相同的数字。


https://blog.csdn.net/JNingWei/article/details/78834173

两步法

  1. 定义计算
  2. 执行计算

计算图

  1. node: operations/variable
  2. edge: tensors

hello world code

1
2
3
4
5
import tensorflow as tf
a = tf.add(3, 5)
sess = tf.Session()
print(sess.run(a))
sess.close()
1
2
3
4
5
6
7
8
9
10
11
# Creates a graph.
with tf.device('/gpu:2'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], name='b')
c = tf.multiply(a, b)

# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

# Runs the op.
print(sess.run(c))
1
2
3
4
5
6
7
8
g1 = tf.get_default_graph()
g2 = tf.Graph()
# add ops to the default graph
with g1.as_default():
a = tf.Constant(3)
# add ops to the user created graph
with g2.as_default():
b = tf.Constant(5)