本文整理汇总了Python中termcolor.cprint方法的典型用法代码示例。如果您正苦于以下问题:Python termcolor.cprint方法的具体用法?Python termcolor.cprint怎么用?Python termcolor.cprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类termcolor
的用法示例。
在下文中一共展示了termcolor.cprint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: adjust_learning_rate
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def adjust_learning_rate(optimizer, drop_ratio, epoch, lr_drop_epoch_list,
WARMUP_EPOCHS, WARMUP_LRS):
if args.warmup and epoch < WARMUP_EPOCHS:
# achieve the warmup lr
lrs = np.linspace(WARMUP_LRS[0], WARMUP_LRS[1], num=WARMUP_EPOCHS)
cprint('=> warmup lrs {}'.format(lrs), 'green')
for param_group in optimizer.param_groups:
param_group['lr'] = lrs[epoch]
current_lr = lrs[epoch]
else:
decay = drop_ratio if epoch in lr_drop_epoch_list else 1.0
for param_group in optimizer.param_groups:
param_group['lr'] = args.lr * decay
args.lr *= decay
current_lr = args.lr
return current_lr
示例2: setup_tensorboard
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def setup_tensorboard(flags):
"""Creates summary writers, and setups default tensorboard paths."""
if not flags.tensorboard:
return
# --- Do not allow experiment with same name
assert (not tf.io.gfile.exists(flags.logdir) or
not tf.io.gfile.listdir(flags.logdir)), \
"CRITICAL: folder {} already exists".format(flags.logdir)
# --- Log where summary can be found
print("View results with: ")
termcolor.cprint(" tensorboard --logdir {}".format(flags.logdir), "red")
writer = tf.summary.create_file_writer(flags.logdir, flush_millis=10000)
writer.set_as_default()
# --- Log dir name tweak for "hypertune"
log_dir = ""
trial_id = int(os.environ.get("CLOUD_ML_TRIAL_ID", 0))
if trial_id != 0:
if log_dir.endswith(os.sep):
log_dir = log_dir[:-1] # removes trailing "/"
log_dir += "_trial{0:03d}/".format(trial_id)
示例3: run
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def run(self):
#resetEngines()
if not self.check():
return
self.set_arch()
#enableSymbolicEngine(True)
self.optimization()
self.load_binary()
self.set_regs()
self.load_stack()
# make Symbolic
if self.symbolized_argv:
self.symbolize_argv()
self.symbolize_memory()
# symbolic execution
if not self.emulate(self.registers[Arch().pc_reg]):
print(cprint("No answer is found!!!", 'red'))
# Commands
示例4: _observe
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def _observe(self):
#cprint('Observe called!', 'yellow')
if self.config['USE_XVFB']:
offset_x = 0
offset_y = 0
else:
offset_x = self.config['OFFSET_X']
offset_y = self.config['OFFSET_Y']
image_array = \
np.array(self.mss_grabber.grab({"top": offset_y,
"left": offset_x,
"width": SCR_W,
"height": SCR_H}),
dtype=np.uint8)
# drop the alpha channel and flip red and blue channels (BGRA -> RGB)
self.pixel_array = np.flip(image_array[:, :, :3], 2)
return self.pixel_array
示例5: handle_keyboard_interrupt
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def handle_keyboard_interrupt(flags):
"""Informs user how to delete stale summaries."""
print("Keyboard interrupt by user")
if flags.logdir.startswith("gs://"):
bucketpath = flags.logdir[5:]
print("Delete these summaries with: ")
termcolor.cprint(" gsutil rm -rf {}".format(flags.logdir), "red")
baseurl = " https://pantheon.google.com/storage/browser/{}"
print("Or by visiting: ")
termcolor.cprint(baseurl.format(bucketpath), "red")
else:
print("Delete these summaries with: ")
termcolor.cprint(" rm -rf {}".format(flags.logdir), "red")
示例6: log_print
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def log_print(text, color=None, on_color=None, attrs=None):
if cprint is not None:
cprint(text, color=color, on_color=on_color, attrs=attrs)
else:
print(text)
示例7: cprint
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def cprint(text, color):
print(text)
示例8: fail
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def fail(text):
cprint(text, 'red')
示例9: win
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def win(text):
cprint(text, 'green')
示例10: banner
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def banner(text):
cprint(Figlet().renderText(text), "blue")
示例11: c
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def c(msg, colour):
try:
from termcolor import colored, cprint
p = lambda x: cprint(x, '%s' % colour)
return p(msg)
except:
print (msg)
示例12: load_from_id
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def load_from_id(bsuite_id: str) -> base.Environment:
"""Returns a bsuite environment given a bsuite_id."""
kwargs = sweep.SETTINGS[bsuite_id]
experiment_name, _ = unpack_bsuite_id(bsuite_id)
env = load(experiment_name, kwargs)
termcolor.cprint(
f'Loaded bsuite_id: {bsuite_id}.', color='white', attrs=['bold'])
return env
示例13: load_and_record_to_sqlite
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def load_and_record_to_sqlite(bsuite_id: str,
db_path: str) -> dm_env.Environment:
"""Returns a bsuite environment that saves results to an SQLite database.
The returned environment will automatically save the results required for
the analysis notebook when stepping through the environment.
To load the results, specify the file path in the provided notebook, or to
manually inspect the results use:
```python
from bsuite.utils import sqlite_load
results_df, sweep_vars = sqlite_load.load_bsuite('/path/to/database.db')
```
Args:
bsuite_id: The bsuite id identifying the environment to return. For example,
"catch/0" or "deep_sea/3".
db_path: Path to the database file for this set of results. The file will be
created if it does not already exist. When generating results using
multiple different processes, specify the *same* db_path for every
bsuite_id.
Returns:
A bsuite environment determined by the bsuite_id.
"""
raw_env = load_from_id(bsuite_id)
experiment_name, setting_index = unpack_bsuite_id(bsuite_id)
termcolor.cprint(
f'Logging results to SQLite database in {db_path}.',
color='yellow',
attrs=['bold'])
return sqlite_logging.wrap_environment(
env=raw_env,
db_path=db_path,
experiment_name=experiment_name,
setting_index=setting_index,
)
示例14: load_and_record_to_csv
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def load_and_record_to_csv(bsuite_id: str,
results_dir: str,
overwrite: bool = False) -> dm_env.Environment:
"""Returns a bsuite environment that saves results to CSV.
To load the results, specify the file path in the provided notebook, or to
manually inspect the results use:
```python
from bsuite.utils import csv_load
results_df, sweep_vars = csv_load.load_bsuite(results_dir)
```
Args:
bsuite_id: The bsuite id identifying the environment to return. For example,
"catch/0" or "deep_sea/3".
results_dir: Path to the directory to store the resultant CSV files. Note
that this logger will generate a separate CSV file for each bsuite_id.
overwrite: Whether to overwrite existing CSV files if found.
Returns:
A bsuite environment determined by the bsuite_id.
"""
raw_env = load_from_id(bsuite_id)
termcolor.cprint(
f'Logging results to CSV file for each bsuite_id in {results_dir}.',
color='yellow',
attrs=['bold'])
return csv_logging.wrap_environment(
env=raw_env,
bsuite_id=bsuite_id,
results_dir=results_dir,
overwrite=overwrite,
)
示例15: load_and_record_to_terminal
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import cprint [as 别名]
def load_and_record_to_terminal(bsuite_id: str) -> dm_env.Environment:
"""Returns a bsuite environment that logs to terminal."""
raw_env = load_from_id(bsuite_id)
termcolor.cprint(
'Logging results to terminal.', color='yellow', attrs=['bold'])
return terminal_logging.wrap_environment(raw_env)