1. spaces
spaces.Box(low=None, high=None, shape=None, dtype=None)
#例子
b= paces.Box(0.0, float('inf'), [n_dims], dtype=np.float32)
# low=0.0, high=inf , shape=740, dtype= float32
c= spaces.Box(0.0, 1.0, [self._env.action_space.n], dtype=np.float32)
# low=0.0, high=1, shape=71, dtype= float32
2. lambda ,reduce
reduce: 累加
n_dims = reduce(lambda x, y: x+len(list(y)), list(self.stat_type.values()), 0) + len(self.stat_type)*2
拆分:
values=str('00110001000001')
print(list(values),0)
# 输出['0', '0', '1', '1', '0', '0', '0', '1', '0', '0', '0', '0', '0', '1'] 0
a= lambda x, y: x+len(list(y))
b= a(0,values)
print(a) # 输出 <function <lambda> at 0x000001E3DAB21400>
print(b) # 输出 14
3.相关激活函数
4.奇异值分解
代码 解释
线性代数 解释
5. logits
这个将的特别好,解释了交叉熵是如何计算的
6. tf.reduce_mean
tf.reduce_mean 函数用于计算张量tensor沿着指定的数轴(tensor的某一维度)上的的平均值,主要用作降维或者计算tensor(图像)的平均值
7. 交叉熵
用于度量两个概率分布之间的差异,值越小,模型预测的效果越好
softmax_cross_entropy_with_logits( labels=None, logits=None,dim=1,name=None)
#计算 lable和logis之间的交叉熵
#衡量离散分类任务中的概率误差
参数:
labels: 每一行`labels[i]`必须是一个有效的概率分布
logits: 不加标度的对数概率
dim:类的维度。默认为最后一个维度 -1
name:这个操作的名字(可选)
分析:分局交叉熵的概念,labels 为真实值,logits为预测值,此函数的目的是计算labels和logits之间的差距
8. tf.one_hot(indices,depth)
返回一个 one_hot 类型的张量
官方给的例子比较清楚
indices = [0, 1, 2]
depth = 3
tf.one_hot(indices, depth)
#输出为 [3 x 3]
# [[1., 0., 0.],
# [0., 1., 0.],
# [0., 0., 1.]]
indices = [0, 2, -1, 1]
depth = 3
tf.one_hot(indices, depth, on_value=5.0, off_value=0.0,axis=-1)
# output: [4 x 3]
# [[5.0, 0.0, 0.0], # one_hot(0)
# [0.0, 0.0, 5.0], # one_hot(2)
# [0.0, 0.0, 0.0], # one_hot(-1)
# [0.0, 5.0, 0.0]] # one_hot(1)
参数意义:
indices: 输入,即想要进行ONE_HOT转变的,多为矩阵
depth:输出的尺度
on_value 和 off_value:
one_hot默认为1,0表示,1就是on_value, 0就是 off_value,这里可通过设置改变
axis: 要填充的轴(默认:-1)
9. isinstance
https://m.runoob.com/python/python-func-isinstance.html
isinstance() 函数来判断一个对象是否是一个已知的类型,类似 type()
10.axis
总是搞不清楚维度,这个讲得很清楚
11. tf.greater(),tf.to_float,tf.reduce_mean()
import tensorflow as tf
x=[1,2,3,4]
y=[2,1,3,8]
sess=tf.Session()
with sess.as_default():
a=sess.run(tf.greater(x,y))
b=sess.run(tf.to_float(a))
c=sess.run(tf.reduce_mean(b))
print(a,b,c)
#输出
#a=[False True False False]
#b=[0. 1. 0. 0.]
#c= 0.25
12. 查看 tensorflow 是GPU版本 还是CPU版本
import os
from tensorflow.python.client import device_lib
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "99"
if __name__ == "__main__":
print(device_lib.list_local_devices())
13. 查看电脑GPU
cmd : cd C:\Program Files\NVIDIA Corporation\NVSMI 中
cmd 输入 nvidia-smi
这里解释了显示的内容
14. tensorflow GPU
1. 卸载之前环境里的所有有关tensorflow的包
2.安装 GPU版本, 参考 https://blog.csdn.net/zqx951102/article/details/89105110
3. 测试查看 (根据12)
4. 查看分配:https://blog.csdn.net/fanzonghao/article/details/82218621
15. np.concatenate
拼接矩阵:这里
16.Python ZMQ相关内容
1. 基本三个模型 这里
2.参数类型 这里
17. Pycharm导入包
看源码时发现,项目内部的包无法导入,解决办法:https://blog.csdn.net/xiao_yi_xiao/article/details/101793655
发现无法整体导入就一个个文件夹导入
18. 安装全部requirems的包命令
https://blog.csdn.net/weixin_45092662/article/details/106906719
前提是你的python和包的版本正确,安装了几次发现由于版本错误没安装成功,最后是一个个安装的。
19.