本文整理汇总了Python中tensorpack.logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python logger.info方法的具体用法?Python logger.info怎么用?Python logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorpack.logger
的用法示例。
在下文中一共展示了logger.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_heirarchical
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def _update_heirarchical(self):
self.action_angle_step = int(self.action_angle_step/2)
self.action_dist_step = self.action_dist_step-1
if (self.spacing[0] > 1): self.spacing -= 1
self._groundTruth_plane = Plane(*getACPCPlaneFromLandmarks(
self.sitk_image,
self._origin3d_point.astype('float'),
self.ac_point, self.pc_point,
self.midsag_point,
self._plane_size, self.spacing))
# self._groundTruth_plane = Plane(*getMidSagPlaneFromLandmarks(
# self.sitk_image,
# self._origin3d_point.astype('float'),
# self.ac_point, self.pc_point,
# self.midsag_point,
# self._plane_size, self.spacing))
# logger.info('update hierarchical - spacing = {} - angle step = {} - dist step = {}'.format(self.spacing,self.action_angle_step,self.action_dist_step))
示例2: _update_history
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def _update_history(self):
''' update history buffer with current state
'''
# update location history
self._loc_history[:-1] = self._loc_history[1:]
# loc = self._plane.origin
loc = self._plane.params
# logger.info('loc {}'.format(loc))
self._loc_history[-1] = (np.around(loc[0],decimals=2),
np.around(loc[1],decimals=2),
np.around(loc[2],decimals=2),
np.around(loc[3],decimals=2))
# update distance history
self._dist_history.append(self.cur_dist)
self._dist_history_params.append(self.cur_dist_params)
# update params history
self._plane_history.append(self._plane)
self._bestq_history.append(np.max(self._qvalues))
# update q-value history
self._qvalues_history[:-1] = self._qvalues_history[1:]
self._qvalues_history[-1] = self._qvalues
示例3: _update_history
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def _update_history(self):
''' update history buffer with current state
'''
# update location history
self._loc_history[:-1] = self._loc_history[1:]
loc = self._plane.origin
loc = self._plane.params
# logger.info('loc {}'.format(loc))
self._loc_history[-1] = (np.around(loc[0],decimals=2),
np.around(loc[1],decimals=2),
np.around(loc[2],decimals=2),
np.around(loc[3],decimals=2))
# update distance history
self._dist_history.append(self.cur_dist)
self._dist_history_params.append(self.cur_dist_params)
# update params history
self._plane_history.append(self._plane)
self._bestq_history.append(np.max(self._qvalues))
# update q-value history
self._qvalues_history[:-1] = self._qvalues_history[1:]
self._qvalues_history[-1] = self._qvalues
示例4: _oscillate
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def _oscillate(self):
''' Return True if the agent is stuck and oscillating
'''
counter = Counter(self._loc_history)
freq = counter.most_common()
# return false is history is empty (begining of the game)
if len(freq) < 2: return False
# check frequency
if freq[0][0] == (0,0,0,0):
if (freq[1][1]>2):
# logger.info('oscillating {}'.format(self._loc_history))
return True
else:
return False
elif (freq[0][1]>2):
# logger.info('oscillating {}'.format(self._loc_history))
return True
示例5: guess_inputs
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def guess_inputs(input_dir):
meta_candidates = []
model_candidates = []
for path in os.listdir(input_dir):
if path.startswith('graph-') and path.endswith('.meta'):
meta_candidates.append(path)
if path.startswith('model-') and path.endswith('.index'):
modelid = int(path[len('model-'):-len('.index')])
model_candidates.append((path, modelid))
assert len(meta_candidates)
meta = sorted(meta_candidates)[-1]
if len(meta_candidates) > 1:
logger.info("Choosing {} from {} as graph file.".format(meta, meta_candidates))
else:
logger.info("Choosing {} as graph file.".format(meta))
assert len(model_candidates)
model = sorted(model_candidates, key=lambda x: x[1])[-1][0]
if len(model_candidates) > 1:
logger.info("Choosing {} from {} as model file.".format(model, [x[0] for x in model_candidates]))
else:
logger.info("Choosing {} as model file.".format(model))
return os.path.join(input_dir, model), os.path.join(input_dir, meta)
示例6: get_config
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def get_config(model, fake=False, data_aug=True):
nr_tower = max(get_nr_gpu(), 1)
batch = TOTAL_BATCH_SIZE // nr_tower
if fake:
logger.info("For benchmark, batch size is fixed to 64 per tower.")
dataset_train = FakeData(
[[64, 224, 224, 3], [64]], 1000, random=False, dtype='uint8')
callbacks = []
else:
logger.info("Running on {} towers. Batch size per tower: {}".format(nr_tower, batch))
dataset_train = get_data('train', batch, data_aug)
dataset_val = get_data('val', batch, data_aug)
callbacks = [
ModelSaver(),
]
if data_aug:
callbacks.append(ScheduledHyperParamSetter('learning_rate',
[(30, 1e-2), (60, 1e-3), (85, 1e-4), (95, 1e-5), (105, 1e-6)]))
callbacks.append(HumanHyperParamSetter('learning_rate'))
infs = [ClassificationError('wrong-top1', 'val-error-top1'),
ClassificationError('wrong-top5', 'val-error-top5')]
if nr_tower == 1:
# single-GPU inference with queue prefetch
callbacks.append(InferenceRunner(QueueInput(dataset_val), infs))
else:
# multi-GPU inference (with mandatory queue prefetch)
callbacks.append(DataParallelInferenceRunner(
dataset_val, infs, list(range(nr_tower))))
return AutoResumeTrainConfig(
model=model,
dataflow=dataset_train,
callbacks=callbacks,
steps_per_epoch=5000 if TOTAL_BATCH_SIZE == 256 else 10000,
max_epoch=110 if data_aug else 64,
nr_tower=nr_tower
)
示例7: step
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def step(self, action, q_values):
ob, reward, done, info = self.env.step(action, q_values)
self.frames.append(ob)
return self._observation(), reward, done, info
示例8: decode
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def decode(self, filename, label=False):
""" decode a single nifti image
Args
filename: string for input images
label: True if nifti image is label
Returns
image: an image container with attributes; name, data, dims
"""
image = ImageRecord()
image.name = filename
assert self._is_nifti(image.name), "unknown image format for %r" % image.name
if label:
sitk_image = sitk.ReadImage(image.name, sitk.sitkInt8)
else:
sitk_image = sitk.ReadImage(image.name, sitk.sitkFloat32)
np_image = sitk.GetArrayFromImage(sitk_image)
# threshold image between p10 and p98 then re-scale [0-255]
p0 = np_image.min().astype('float')
p10 = np.percentile(np_image, 10)
p99 = np.percentile(np_image, 99)
p100 = np_image.max().astype('float')
# logger.info('p0 {} , p5 {} , p10 {} , p90 {} , p98 {} , p100 {}'.format(p0,p5,p10,p90,p98,p100))
sitk_image = sitk.Threshold(sitk_image,
lower=p10,
upper=p100,
outsideValue=p10)
sitk_image = sitk.Threshold(sitk_image,
lower=p0,
upper=p99,
outsideValue=p99)
sitk_image = sitk.RescaleIntensity(sitk_image,
outputMinimum=0,
outputMaximum=255)
# Convert from [depth, width, height] to [width, height, depth]
image.data = sitk.GetArrayFromImage(sitk_image).transpose(2, 1, 0) #.astype('uint8')
image.dims = np.shape(image.data)
return sitk_image, image
示例9: _calc_reward_params
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def _calc_reward_params(self, prev_params, next_params):
''' Calculate the new reward based on the euclidean distance to the target plane
'''
# logger.info('prev_params {}'.format(np.around(prev_params,2)))
# logger.info('next_params {}'.format(np.around(next_params,2)))
prev_dist = calcScaledDistTwoParams(self._groundTruth_plane.params,
prev_params,
scale_angle = self.action_angle_step,
scale_dist = self.action_dist_step)
next_dist = calcScaledDistTwoParams(self._groundTruth_plane.params,
next_params,
scale_angle = self.action_angle_step,
scale_dist = self.action_dist_step)
# logger.info('next_dist {} prev_dist {}'.format(next_dist, prev_dist))
return prev_dist - next_dist
示例10: step
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def step(self, action, qvalues):
ob, reward, done, info = self.env.step(action,qvalues)
self.frames.append(ob)
return self._observation(), reward, done, info
示例11: _calc_reward_params
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def _calc_reward_params(self, prev_params, next_params):
''' Calculate the new reward based on the euclidean distance to the target plane
'''
# logger.info('prev_params {}'.format(np.around(prev_params,2)))
# logger.info('next_params {}'.format(np.around(next_params,2)))
prev_dist = calcScaledDistTwoParams(self._groundTruth_plane.params,
prev_params,
scale_angle = self.action_angle_step,
scale_dist = self.action_dist_step)
next_dist = calcScaledDistTwoParams(self._groundTruth_plane.params,
next_params,
scale_angle = self.action_angle_step,
scale_dist = self.action_dist_step)
return prev_dist - next_dist
示例12: decode
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def decode(self, filename,label=False):
""" decode a single nifti image
Args
filename: string for input images
label: True if nifti image is label
Returns
image: an image container with attributes; name, data, dims
"""
image = ImageRecord()
image.name = filename
assert self._is_nifti(image.name), "unknown image format for %r" % image.name
if label:
sitk_image = sitk.ReadImage(image.name, sitk.sitkInt8)
else:
sitk_image = sitk.ReadImage(image.name, sitk.sitkFloat32)
np_image = sitk.GetArrayFromImage(sitk_image)
# threshold image between p10 and p98 then re-scale [0-255]
p0 = np_image.min().astype('float')
p10 = np.percentile(np_image,10)
p99 = np.percentile(np_image,99)
p100 = np_image.max().astype('float')
# logger.info('p0 {} , p5 {} , p10 {} , p90 {} , p98 {} , p100 {}'.format(p0,p5,p10,p90,p98,p100))
sitk_image = sitk.Threshold(sitk_image,
lower=p10,
upper=p100,
outsideValue=p10)
sitk_image = sitk.Threshold(sitk_image,
lower=p0,
upper=p99,
outsideValue=p99)
sitk_image = sitk.RescaleIntensity(sitk_image,
outputMinimum=0,
outputMaximum=255)
# Convert from [depth, width, height] to [width, height, depth]
# stupid simpleitk
image.data = sitk.GetArrayFromImage(sitk_image).transpose(2,1,0)#.astype('uint8')
image.dims = np.shape(image.data)
return sitk_image, image
示例13: _import_external_ops
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def _import_external_ops(message):
if "horovod" in message.lower():
logger.info("Importing horovod ...")
import horovod.tensorflow # noqa
return
if "MaxBytesInUse" in message:
logger.info("Importing memory_stats ...")
from tensorflow.contrib.memory_stats import MaxBytesInUse # noqa
return
if 'Nccl' in message:
logger.info("Importing nccl ...")
if TF_version <= (1, 12):
try:
from tensorflow.contrib.nccl.python.ops.nccl_ops import _validate_and_load_nccl_so
except Exception:
pass
else:
_validate_and_load_nccl_so()
from tensorflow.contrib.nccl.ops import gen_nccl_ops # noqa
else:
from tensorflow.python.ops import gen_nccl_ops # noqa
return
if 'ZMQConnection' in message:
import zmq_ops # noqa
return
logger.error("Unhandled error: " + message)
示例14: step
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def step(self, act, q_values,isOver):
for i in range(0,self.agents):
if isOver[i]: act[i]=15
current_st, reward, terminal, info = self.env.step(act, q_values, isOver)
# for i in range(0,self.agents):
current_st=tuple(current_st)
self.frames.append(current_st)
return self._observation(),reward, terminal, info
示例15: decode
# 需要导入模块: from tensorpack import logger [as 别名]
# 或者: from tensorpack.logger import info [as 别名]
def decode(self, filename,label=False):
""" decode a single nifti image
Args
filename: string for input images
label: True if nifti image is label
Returns
image: an image container with attributes; name, data, dims
"""
image = ImageRecord()
image.name = filename
assert self._is_nifti(image.name), "unknown image format for %r" % image.name
if label:
sitk_image = sitk.ReadImage(image.name, sitk.sitkInt8)
else:
sitk_image = sitk.ReadImage(image.name, sitk.sitkFloat32)
np_image = sitk.GetArrayFromImage(sitk_image)
# threshold image between p10 and p98 then re-scale [0-255]
p0 = np_image.min().astype('float')
p10 = np.percentile(np_image,10)
p99 = np.percentile(np_image,99)
p100 = np_image.max().astype('float')
# logger.info('p0 {} , p5 {} , p10 {} , p90 {} , p98 {} , p100 {}'.format(p0,p5,p10,p90,p98,p100))
sitk_image = sitk.Threshold(sitk_image,
lower=p10,
upper=p100,
outsideValue=p10)
sitk_image = sitk.Threshold(sitk_image,
lower=p0,
upper=p99,
outsideValue=p99)
sitk_image = sitk.RescaleIntensity(sitk_image,
outputMinimum=0,
outputMaximum=255)
# Convert from [depth, width, height] to [width, height, depth]
image.data = sitk.GetArrayFromImage(sitk_image).transpose(2,1,0)#.astype('uint8')
image.dims = np.shape(image.data)
return sitk_image, image