本文整理汇总了Python中task.Task方法的典型用法代码示例。如果您正苦于以下问题:Python task.Task方法的具体用法?Python task.Task怎么用?Python task.Task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类task
的用法示例。
在下文中一共展示了task.Task方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import task [as 别名]
# 或者: from task import Task [as 别名]
def main():
parser = argparse.ArgumentParser(description=None)
parser.add_argument('-t', '--task', default='CartPole-v0',
type=str, help='Tasks: CartPole-v0, Pendulum-v0, Acrobot-v1')
parser.add_argument('-d', '--device', default='cpu', type=str, help='Device: cpu, gpu')
args = parser.parse_args()
task = Task(args.task)
log_dir = os.path.join(DEMO['log_dir'], '{}/train'.format(args.task))
if not tf.gfile.Exists(log_dir):
tf.gfile.MakeDirs(log_dir)
model_dir = os.path.join(DEMO['log_dir'], args.task)
device = '/{}:0'.format('cpu')
with tf.device(device):
model = DPG(DEMO, task, model_dir, callback=task.render)
with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess:
saver = tf.train.Saver()
model.load(sess, saver)
model.evaluate(sess)
示例2: main
# 需要导入模块: import task [as 别名]
# 或者: from task import Task [as 别名]
def main():
parser = argparse.ArgumentParser(description=None)
parser.add_argument('-t', '--task', default='CartPole-v0',
type=str, help='Tasks: CartPole-v0, Pendulum-v0, Acrobot-v1')
parser.add_argument('-d', '--device', default='cpu', type=str, help='Device: cpu, gpu')
args = parser.parse_args()
task = Task(args.task)
log_dir = os.path.join(DEMO['log_dir'], '{}/train'.format(args.task))
if not tf.gfile.Exists(log_dir):
tf.gfile.MakeDirs(log_dir)
model_dir = os.path.join(DEMO['log_dir'], args.task)
device = '/{}:0'.format(args.device)
with tf.device(device):
model = DPG(DEMO, task, model_dir, callback=None)
with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess:
saver = tf.train.Saver()
writer = tf.summary.FileWriter(delete_dir(log_dir), sess.graph_def)
model.set_summary_writer(summary_writer=writer)
sess.run(tf.global_variables_initializer())
model.train(sess, saver)
示例3: main
# 需要导入模块: import task [as 别名]
# 或者: from task import Task [as 别名]
def main(options):
if options.epoch:
time_str = datetime.datetime.now().isoformat()
logname = "Eval_[Model@%s]_[Data@%s]_%s.log" % (options.model_name,
options.data_name, time_str)
logger = logging_utils._get_logger(config.LOG_DIR, logname)
else:
time_str = datetime.datetime.now().isoformat()
logname = "Final_[Model@%s]_[Data@%s]_%s.log" % (options.model_name,
options.data_name, time_str)
logger = logging_utils._get_logger(config.LOG_DIR, logname)
# logger = logging.getLogger()
# logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s', level=logging.INFO)
params_dict = param_space_dict[options.model_name]
task = Task(options.model_name, options.data_name, options.runs, params_dict, logger)
if options.save:
task.save()
else:
if options.epoch:
task.refit()
else:
task.evaluate(options.full)
示例4: main
# 需要导入模块: import task [as 别名]
# 或者: from task import Task [as 别名]
def main(options):
time_str = datetime.datetime.now().isoformat()
logname = "Final_[Model@%s]_%s.log" % (options.model_name, time_str)
logger = logging_utils._get_logger(config.LOG_DIR, logname)
params_dict = param_space_dict[options.model_name]
task = Task(options.model_name, options.runs, params_dict, logger)
task.evaluate(options.prefix)
示例5: __init__
# 需要导入模块: import task [as 别名]
# 或者: from task import Task [as 别名]
def __init__(self, omci_agent, device_id, frame, priority=task_priority, exclusive=False):
"""
Class initialization
:param omci_agent: (OmciAdapterAgent) OMCI Adapter agent
:param device_id: (str) ONU Device ID
:param frame: (OmciFrame) Frame to send
:param priority: (int) OpenOMCI Task priority (0..255) 255 is the highest
:param exclusive: (bool) True if this GET request Task exclusively own the
OMCI-CC while running. Default: False
"""
super(OmciModifyRequest, self).__init__(OmciModifyRequest.name,
omci_agent,
device_id,
priority=priority,
exclusive=exclusive)
self._device = omci_agent.get_device(device_id)
self._frame = frame
self._results = None
self._local_deferred = None
# Validate message type
self._msg_type = frame.fields['message_type']
if self._msg_type not in (OmciCreate.message_id, OmciSet.message_id, OmciDelete.message_id):
raise TypeError('Invalid Message type: {}, must be Create, Set, or Delete'.
format(self._msg_type))
示例6: __init__
# 需要导入模块: import task [as 别名]
# 或者: from task import Task [as 别名]
def __init__(self, omci_agent, device_id, entity_class, serial_number,
logical_device_id,
exclusive=True, allow_failure=False, **kwargs):
"""
Class initialization
:param omci_agent: (OmciAdapterAgent) OMCI Adapter agent
:param device_id: (str) ONU Device ID
:param entity_class: (EntityClass) ME Class to retrieve
:param entity_id: (int) ME Class instance ID to retrieve
:param attributes: (list or set) Name of attributes to retrieve
:param exclusive: (bool) True if this GET request Task exclusively own the
OMCI-CC while running. Default: True
:param allow_failure: (bool) If true, attempt to get all valid attributes
if the original request receives an error
code of 9 (Attributes failed or unknown).
"""
super(OmciTestRequest, self).__init__(OmciTestRequest.name,
omci_agent,
device_id,
priority=OmciTestRequest.task_priority,
exclusive=exclusive)
self._device = omci_agent.get_device(device_id)
self._entity_class = entity_class
self._allow_failure = allow_failure
self._failed_or_unknown_attributes = set()
self._results = None
self._local_deferred = None
self.device_id = device_id
self.event_bus = EventBusClient()
self.lc = None
self.default_freq = self.default_freq = \
kwargs.get(OmciTestRequest.DEFAULT_FREQUENCY_KEY,
OmciTestRequest.DEFAULT_COLLECTION_FREQUENCY)
self.serial_number = serial_number
self.logical_device_id = logical_device_id
topic = 'omci-rx:{}:{}'.format(self.device_id, 'Test_Result')
self.msg = self.event_bus.subscribe(topic, self.process_messages)
示例7: __init__
# 需要导入模块: import task [as 别名]
# 或者: from task import Task [as 别名]
def __init__(self, omci_agent, device_id, entity_class, entity_id, attributes,
exclusive=True, allow_failure=False):
"""
Class initialization
:param omci_agent: (OmciAdapterAgent) OMCI Adapter agent
:param device_id: (str) ONU Device ID
:param entity_class: (EntityClass) ME Class to retrieve
:param entity_id: (int) ME Class instance ID to retrieve
:param attributes: (list or set) Name of attributes to retrieve
:param exclusive: (bool) True if this GET request Task exclusively own the
OMCI-CC while running. Default: True
:param allow_failure: (bool) If true, attempt to get all valid attributes
if the original request receives an error
code of 9 (Attributes failed or unknown).
"""
super(OmciGetRequest, self).__init__(OmciGetRequest.name,
omci_agent,
device_id,
priority=OmciGetRequest.task_priority,
exclusive=exclusive)
self._device = omci_agent.get_device(device_id)
self._entity_class = entity_class
self._entity_id = entity_id
self._attributes = attributes
self._allow_failure = allow_failure
self._failed_or_unknown_attributes = set()
self._results = None
self._local_deferred = None