當前位置: 首頁>>代碼示例>>Python>>正文


Python termcolor.cprint方法代碼示例

本文整理匯總了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 
開發者ID:KaiyuYue,項目名稱:cgnl-network.pytorch,代碼行數:18,代碼來源:train_val.py

示例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) 
開發者ID:tensorflow,項目名稱:graphics,代碼行數:25,代碼來源:helpers.py

示例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 
開發者ID:SQLab,項目名稱:symgdb,代碼行數:25,代碼來源:symgdb.py

示例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 
開發者ID:bzier,項目名稱:gym-mupen64plus,代碼行數:23,代碼來源:mupen64plus_env.py

示例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") 
開發者ID:tensorflow,項目名稱:graphics,代碼行數:15,代碼來源:helpers.py

示例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) 
開發者ID:svishwa,項目名稱:crowdcount-mcnn,代碼行數:7,代碼來源:train.py

示例7: cprint

# 需要導入模塊: import termcolor [as 別名]
# 或者: from termcolor import cprint [as 別名]
def cprint(text, color):
        print(text) 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:4,代碼來源:test.py

示例8: fail

# 需要導入模塊: import termcolor [as 別名]
# 或者: from termcolor import cprint [as 別名]
def fail(text):
    cprint(text, 'red') 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:4,代碼來源:test.py

示例9: win

# 需要導入模塊: import termcolor [as 別名]
# 或者: from termcolor import cprint [as 別名]
def win(text):
    cprint(text, 'green') 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:4,代碼來源:test.py

示例10: banner

# 需要導入模塊: import termcolor [as 別名]
# 或者: from termcolor import cprint [as 別名]
def banner(text):
    cprint(Figlet().renderText(text), "blue") 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:4,代碼來源:test.py

示例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) 
開發者ID:ztwo,項目名稱:Auto_Analysis,代碼行數:9,代碼來源:Utils.py

示例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 
開發者ID:deepmind,項目名稱:bsuite,代碼行數:10,代碼來源:bsuite.py

示例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,
  ) 
開發者ID:deepmind,項目名稱:bsuite,代碼行數:41,代碼來源:bsuite.py

示例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,
  ) 
開發者ID:deepmind,項目名稱:bsuite,代碼行數:37,代碼來源:bsuite.py

示例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) 
開發者ID:deepmind,項目名稱:bsuite,代碼行數:8,代碼來源:bsuite.py


注:本文中的termcolor.cprint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。