Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

实现多类型观测值存储和学习 #33

Closed
StepNeverStop opened this issue Jan 5, 2021 · 3 comments
Closed

实现多类型观测值存储和学习 #33

StepNeverStop opened this issue Jan 5, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request optimization Better performance or solution
Projects

Comments

@StepNeverStop
Copy link
Owner

  • 向量
  • 射线
  • 多图像
@StepNeverStop StepNeverStop created this issue from a note in Tasks (To Do) Jan 5, 2021
@StepNeverStop StepNeverStop moved this from To Do to In Progress in Tasks Jan 5, 2021
StepNeverStop added a commit that referenced this issue Jan 5, 2021
- fix `sac`
- fix `is_continuous` of unity wrapper
- rename `*DEC` to `*DCT`
@StepNeverStop StepNeverStop added the enhancement New feature or request label Jan 5, 2021
@StepNeverStop StepNeverStop self-assigned this Jan 5, 2021
StepNeverStop added a commit that referenced this issue Jan 5, 2021
- support multi-vector and multi-visual input
- optimize `gym` and `unity` wrapper
- fix `ActorCriticValueCts`
- tag 2.0.0
- add `ObsSpec`
- refactor `SingleAgentEnvArgs` and `MultiAgentEnvArgs`
- remove `self.s_dim`, use `self.concat_vector_dim` instead
- stop using vector input normalization temporarily
@StepNeverStop
Copy link
Owner Author

目前已经实现了基于NamedTuple的数据格式,对于智能体的观测状态,其必须被赋值vectorvisual两个字段,如果智能体仅包含向量/图像输入,其另一项被默认赋值为np.full((n_agents, 0), []),这在一定程度上浪费了存储内存,因此测试一下该默认值所消耗的内存大小,代码如下:

import sys
import numpy as np

empty10_0 = np.full((10,0), [])
empty1000_0 = np.full((1000,0), [])

random10_1 = np.random.random((10, 1))
random1000_1 = np.random.random((1000, 1))

def f(x):
    return sys.getsizeof(x)

print(f(()), f([]), f([[]]),f(np.asarray([])), f(np.asarray([[]])))
print(f(empty10_0), f(empty1000_0), f(random10_1), f(random1000_1))

最后结果输出为:

56 72 80 96 112
112 112 192 8112

由此可见,二维的空numpy数组,无论shape如何,其恒占用112个bytes,不算很多,但是当存储的经验较多时,依旧会空消耗不少内存,因此有待优化。

@StepNeverStop
Copy link
Owner Author

StepNeverStop commented Jan 5, 2021

另外,在测试NamedTuplenamedtupletuple对象所消耗的空间时,得到了迷惑的答案,元组对象所占字节很少,不知为何元组对象内所存numpy矩阵对象的内存并未计算在元组所消耗内存中。

from typing import NamedTuple
from collections import namedtuple

x = np.random.random((100, 100))
y = np.random.random((100, 100))

NT = NamedTuple('a', [('x', np.ndarray),('y', np.ndarray)])(x, y)
nt = namedtuple('a', 'x, y')(x, y)
t = tuple((x,y))

print(f(x), f(y))
print(f(NT), f(nt), f(t))
print(f(NT.x))

结果:

80112 80112
72 72 72
80112

@StepNeverStop
Copy link
Owner Author

  • 实现多向量观测输入时,自适应神经网络结构的功能,比如输出维度为8,则DNN结构可为32->8,如果输入维度为120,则DNN结构可自动推断为256->128->16

@StepNeverStop StepNeverStop added the optimization Better performance or solution label Jan 6, 2021
StepNeverStop added a commit that referenced this issue Jul 4, 2021
1. fixed n-step replay buffer
2. reconstruct representation net
3. remove 'use_stack'
4. implement multi-agent algorithms with shared parameters
5. optimized agent network
@StepNeverStop StepNeverStop moved this from In Progress to Done in Tasks Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request optimization Better performance or solution
Projects
Tasks
  
Done
Development

No branches or pull requests

1 participant