1 Star 0 Fork 0

zhoub86/echo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
agent.py 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
Caryn Tran 提交于 2019-10-22 02:58 . merging with branch:paper
# import models.modulator_models
# import models.demodulator_models
# print(models.modulator_models)
from importlib import import_module
from models.demodulator import Demodulator
from models.modulator import Modulator
# def my_import(name):
# components = name.split('.')
# mod = __import__(components[0])
# for comp in components[1:]:
# mod = getattr(mod, comp)
# return mod
class Agent():
def __init__(self, *, agent_dict, name, verbose=False):
self.name = name
self.to_echo = None
self.actions = None
for function in ['mod', 'demod']:
model = agent_dict['%s_model'%function]
params = agent_dict.get('%s_params'%function, False)
assert params, "agent %s %s_params not defined"%(name, function)
assert params.get('bits_per_symbol', False), "agent %s %s_params['bits_per_symbol'] not defined"%(name, function)
assert params['bits_per_symbol'] in [1,2,3,4], "agent %s %s_params['bits_per_symbol'] is not 1,2,3, or 4"%(name, function)
#### LOAD MODEL
module_name = 'models.%sulator_models.%s'%(function, model.capitalize())
model_class = getattr(import_module(module_name), model.capitalize())
if function == 'demod':
self.demod = Demodulator(model=model_class, verbose=verbose, **params)
else: # function == 'mod'
self.mod = Modulator(model=model_class, verbose=verbose, **params)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhoub86/echo.git
git@gitee.com:zhoub86/echo.git
zhoub86
echo
echo
master

搜索帮助