当前位置: 首页>>代码示例>>Python>>正文


Python logger.info方法代码示例

本文整理汇总了Python中gym.logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python logger.info方法的具体用法?Python logger.info怎么用?Python logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gym.logger的用法示例。


在下文中一共展示了logger.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def make(self, id):
        logger.info('Making new env: %s', id)
        spec = self.spec(id)
        env = spec.make()
        # We used to have people override _reset/_step rather than
        # reset/step. Set _gym_disable_underscore_compat = True on
        # your environment if you use these methods and don't want
        # compatibility code to be invoked.
        if hasattr(env, "_reset") and hasattr(env, "_step") and not getattr(env, "_gym_disable_underscore_compat", False):
            patch_deprecated_methods(env)
        if (env.spec.timestep_limit is not None) and not spec.tags.get('vnc'):
            from gym.wrappers.time_limit import TimeLimit
            env = TimeLimit(env,
                            max_episode_steps=env.spec.max_episode_steps,
                            max_episode_seconds=env.spec.max_episode_seconds)
        return env 
开发者ID:joanby,项目名称:ia-course,代码行数:18,代码来源:registration.py

示例2: make

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def make(self, id):
        logger.info('Making new env: %s', id)
        spec = self.spec(id)
        env = spec.make()
        # We used to have people override _reset/_step rather than
        # reset/step. Set _gym_disable_underscore_compat = True on
        # your environment if you use these methods and don't want
        # compatibility code to be invoked.
        if hasattr(env, "_reset") and hasattr(env, "_step") and not getattr(env, "_gym_disable_underscore_compat", False):
            patch_deprecated_methods(env)
        if (env.spec.timestep_limit is not None) and not spec.tags.get('vnc'):
            from .time_limit import TimeLimit
            env = TimeLimit(env,
                            max_episode_steps=env.spec.max_episode_steps,
                            max_episode_seconds=env.spec.max_episode_seconds)
        return env 
开发者ID:sunblaze-ucb,项目名称:rl-generalization,代码行数:18,代码来源:registration.py

示例3: make

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def make(self, id, kwargs):
        logger.info('Making new env: %s', id)
        spec = registration.spec(id)
        env = spec.make()
        # We used to have people override _reset/_step rather than
        # reset/step. Set _gym_disable_underscore_compat = True on
        # your environment if you use these methods and don't want
        # compatibility code to be invoked.
        if hasattr(env, "_reset") and hasattr(env, "_step") and not getattr(env, "_gym_disable_underscore_compat", False):
            patch_deprecated_methods(env)
        if (env.spec.timestep_limit is not None) and not spec.tags.get('vnc'):
            from gym.wrappers.time_limit import TimeLimit
            env = TimeLimit(env,
                            max_episode_steps=env.spec.max_episode_steps,
                            max_episode_seconds=env.spec.max_episode_seconds)
        return env 
开发者ID:alexsax,项目名称:midlevel-reps,代码行数:18,代码来源:make_env.py

示例4: make

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def make(self, path, **kwargs):
        if len(kwargs) > 0:
            logger.info('Making new env: %s (%s)', path, kwargs)
        else:
            logger.info('Making new env: %s', path)
        spec = self.spec(path)
        env = spec.make(**kwargs)
        # We used to have people override _reset/_step rather than
        # reset/step. Set _gym_disable_underscore_compat = True on
        # your environment if you use these methods and don't want
        # compatibility code to be invoked.
        if hasattr(env, "_reset") and hasattr(env, "_step") and not getattr(env, "_gym_disable_underscore_compat", False):
            patch_deprecated_methods(env)
        if (env.spec.max_episode_steps is not None) and not spec.tags.get('vnc'):
            from gym.wrappers.time_limit import TimeLimit
            env = TimeLimit(env, max_episode_steps=env.spec.max_episode_steps)
        return env 
开发者ID:hust512,项目名称:DQN-DDPG_Stock_Trading,代码行数:19,代码来源:registration.py

示例5: _preprocess

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def _preprocess(self):
        data = pd.read_csv(Generator.dataset_path)
        message = 'Columns found in the dataset {}'.format(data.columns)
        logger.info(message)
        data = data.dropna()
        start_time_stamp = data['Timestamp'][0]
        timestamps = data['Timestamp'].apply(lambda x: (x - start_time_stamp) / 60)
        timestamps = timestamps - range(timestamps.shape[0])
        data.insert(0, 'blocks', timestamps)
        blocks = data.groupby('blocks')
        message = 'Number of blocks of continuous prices found are {}'.format(len(blocks))
        logger.info(message)
        
        self._data_blocks = []
        distinct_episodes = 0

        for name, indices in blocks.indices.items():
            ''' 
            Length of the block should exceed the history length and horizon by 1.
            Extra 1 is required to normalize each price block by previos time stamp
            '''
            if len(indices) > (self.history_length + self.horizon + 1):
                
                self._data_blocks.append(blocks.get_group(name))
                # similarly, we subtract an extra 1 to calculate the number of distinct episodes
                distinct_episodes = distinct_episodes + (len(indices) - (self.history_length + self.horizon) + 1 + 1)

        data = None
        message_list = [
            'Number of usable blocks obtained from the dataset are {}'.format(len(self._data_blocks))
        ]
        message_list.append(
            'Number of distinct episodes for the current configuration are {}'.format(distinct_episodes)
        )
        map(logger.info, message_list) 
开发者ID:samre12,项目名称:gym-cryptotrading,代码行数:37,代码来源:generator.py

示例6: get_transactions

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def get_transactions():
        if not Generator.dataset_path:
            Generator.set_dataset_path()

        message = 'Getting latest transactions from {}.'.format(URL) + \
                    '\nThis might take a few minutes depending upon your internet speed.'
        logger.info(message)
    
        path = os.path.join(Generator.temp_dir, 'coinbaseUSD.csv.gz')
        f = urllib2.urlopen(URL)
        with open(path, 'w') as buffer:
            buffer.write(f.read())
        message = 'Latest transactions saved to {}'.format(path)
        logger.info(message)

        # Read the transactions into pandas dataframe
        with gzip.open(path, 'r') as f:
            d = pd.read_table(f, sep=',', header=None, index_col=0, names=['price', 'volume'])    
        os.remove(path)

        d.index = d.index.map(lambda ts: datetime.datetime.fromtimestamp(int(ts)))
        d.index.names = ['DateTime_UTC']
        p = pd.DataFrame(d['price'].resample('1Min').ohlc())
        p.columns = ['price_open', 'price_high', 'price_low', 'price_close']
        v = pd.DataFrame(d['volume'].resample('1Min').sum())
        v.columns = ['volume']
        p['volume'] = v['volume']
        unix_timestamps = p.index.map(lambda ts: int(time.mktime(ts.timetuple())))
        p.insert(0, 'Timestamp', unix_timestamps)

        p.to_csv(Generator.dataset_path, sep=',')
        message = 'Dataset sampled and saved to {}'.format(Generator.dataset_path)
        logger.info(message) 
开发者ID:samre12,项目名称:gym-cryptotrading,代码行数:35,代码来源:generator.py

示例7: load_gen

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def load_gen():
        if not Generator.dataset_path:
            Generator.set_dataset_path()

        '''
        TODO: Need to do sanity check of the sampled dataset
        '''
        if not os.path.isfile(Generator.dataset_path):
            message = 'Sampled Dataset not found at {}.'.format(Generator.dataset_path) + \
                            '\nSetting up the environment for first use.'
            logger.info(message)
            Generator.get_transactions() 
开发者ID:samre12,项目名称:gym-cryptotrading,代码行数:14,代码来源:generator.py

示例8: test_env_semantics

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def test_env_semantics(spec):
	logger.warn("Skipping this test. Existing hashes were generated in a bad way")	
	return
	with open(ROLLOUT_FILE) as data_file:
		rollout_dict = json.load(data_file)

	if spec.id not in rollout_dict:
		if not spec.nondeterministic:
			logger.warn("Rollout does not exist for {}, run generate_json.py to generate rollouts for new envs".format(spec.id))
		return

	logger.info("Testing rollout for {} environment...".format(spec.id))

	observations_now, actions_now, rewards_now, dones_now = generate_rollout_hash(spec)

	errors = []
	if rollout_dict[spec.id]['observations'] != observations_now:
		errors.append('Observations not equal for {} -- expected {} but got {}'.format(spec.id, rollout_dict[spec.id]['observations'], observations_now))
	if rollout_dict[spec.id]['actions'] != actions_now:
		errors.append('Actions not equal for {} -- expected {} but got {}'.format(spec.id, rollout_dict[spec.id]['actions'], actions_now))
	if rollout_dict[spec.id]['rewards'] != rewards_now:
		errors.append('Rewards not equal for {} -- expected {} but got {}'.format(spec.id, rollout_dict[spec.id]['rewards'], rewards_now))
	if rollout_dict[spec.id]['dones'] != dones_now:
		errors.append('Dones not equal for {} -- expected {} but got {}'.format(spec.id, rollout_dict[spec.id]['dones'], dones_now))
	if len(errors):
		for error in errors:
			logger.warn(error)
		raise ValueError(errors) 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:30,代码来源:test_envs_semantics.py

示例9: make

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def make(self, id):
        logger.info('Making new env: %s', id)
        spec = self.spec(id)
        env = spec.make()
        if hasattr(env, "_reset") and hasattr(env, "_step"):
            patch_deprecated_methods(env)
        if (env.spec.timestep_limit is not None) and not spec.tags.get('vnc'):
            from gym.wrappers.time_limit import TimeLimit
            env = TimeLimit(env,
                            max_episode_steps=env.spec.max_episode_steps,
                            max_episode_seconds=env.spec.max_episode_seconds)
        return env 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:14,代码来源:registration.py

示例10: step

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def step(self, action):
        self._before_step(action)
        observation, reward, done, info = self.env.step(action)
        done = self._after_step(observation, reward, done, info)

        return observation, reward, done, info 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:8,代码来源:monitor.py

示例11: set_monitor_mode

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def set_monitor_mode(self, mode):
        logger.info("Setting the monitor mode is deprecated and will be removed soon")
        self._set_mode(mode) 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:5,代码来源:monitor.py

示例12: _after_step

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def _after_step(self, observation, reward, done, info):
        if not self.enabled: return done

        if done and self.env_semantics_autoreset:
            # For envs with BlockingReset wrapping VNCEnv, this observation will be the first one of the new episode
            self.reset_video_recorder()
            self.episode_id += 1
            self._flush()

        # Record stats
        self.stats_recorder.after_step(observation, reward, done, info)
        # Record video
        self.video_recorder.capture_frame()

        return done 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:17,代码来源:monitor.py

示例13: clear_monitor_files

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def clear_monitor_files(training_dir):
    files = detect_monitor_files(training_dir)
    if len(files) == 0:
        return

    logger.info('Clearing %d monitor files from previous run (because force=True was provided)', len(files))
    for file in files:
        os.unlink(file) 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:10,代码来源:monitor.py

示例14: close

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def close(self):
        """Make sure to manually close, or else you'll leak the encoder process"""
        if not self.enabled:
            return

        if self.encoder:
            logger.debug('Closing video encoder: path=%s', self.path)
            self.encoder.close()
            self.encoder = None
        else:
            # No frames captured. Set metadata, and remove the empty output file.
            os.remove(self.path)

            if self.metadata is None:
                self.metadata = {}
            self.metadata['empty'] = True

        # If broken, get rid of the output file, otherwise we'd leak it.
        if self.broken:
            logger.info('Cleaning up paths for broken video recorder: path=%s metadata_path=%s', self.path, self.metadata_path)

            # Might have crashed before even starting the output file, don't try to remove in that case.
            if os.path.exists(self.path):
                os.remove(self.path)

            if self.metadata is None:
                self.metadata = {}
            self.metadata['broken'] = True

        self.write_metadata() 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:32,代码来源:video_recorder.py

示例15: close

# 需要导入模块: from gym import logger [as 别名]
# 或者: from gym.logger import info [as 别名]
def close(self):
        """Make sure to manually close, or else you'll leak the encoder process"""
        if not self.enabled:
            return

        if self.encoder:
            logger.debug('Closing video encoder: path=%s', self.path)
            self.encoder.close()
            self.encoder = None
        else:
            # No frames captured. Set metadata, and remove the empty output file.
            os.remove(self.path)

            if self.metadata is None:
                self.metadata = {}
            self.metadata['empty'] = True

        # If broken, get rid of the output file, otherwise we'd leak it.
        if self.broken:
            logger.info('Cleaning up paths for broken video recorder: path=%s metadata_path=%s', self.path, self.metadata_path)

            # Might have crashed before even starting the output file, don't try to remove in that case.
            if os.path.exists(self.path):
                os.remove(self.path)

            if self.metadata is None:
                self.metadata = {}
            self.metadata['broken'] = True 
开发者ID:sharadmv,项目名称:parasol,代码行数:30,代码来源:utils.py


注:本文中的gym.logger.info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。