本文整理匯總了Python中tensorboard_logger.Logger方法的典型用法代碼示例。如果您正苦於以下問題:Python tensorboard_logger.Logger方法的具體用法?Python tensorboard_logger.Logger怎麽用?Python tensorboard_logger.Logger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorboard_logger
的用法示例。
在下文中一共展示了tensorboard_logger.Logger方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def main(args):
datadir = get_data_dir(args.db)
outputdir = get_output_dir(args.db)
logger = None
if args.tensorboard:
# One should create folder for storing logs
loggin_dir = os.path.join(outputdir, 'runs', 'pretraining')
if not os.path.exists(loggin_dir):
os.makedirs(loggin_dir)
loggin_dir = os.path.join(loggin_dir, '%s' % (args.id))
if args.clean_log:
remove_files_in_dir(loggin_dir)
logger = Logger(loggin_dir)
use_cuda = torch.cuda.is_available()
# Set the seed for reproducing the results
random.seed(args.manualSeed)
np.random.seed(args.manualSeed)
torch.manual_seed(args.manualSeed)
if use_cuda:
torch.cuda.manual_seed_all(args.manualSeed)
torch.backends.cudnn.enabled = True
cudnn.benchmark = True
kwargs = {'num_workers': 0, 'pin_memory': True} if use_cuda else {}
trainset = DCCPT_data(root=datadir, train=True, h5=args.h5)
testset = DCCPT_data(root=datadir, train=False, h5=args.h5)
nepoch = int(np.ceil(np.array(args.niter * args.batchsize, dtype=float) / len(trainset)))
step = int(np.ceil(np.array(args.step * args.batchsize, dtype=float) / len(trainset)))
trainloader = torch.utils.data.DataLoader(trainset, batch_size=args.batchsize, shuffle=True, **kwargs)
testloader = torch.utils.data.DataLoader(testset, batch_size=100, shuffle=True, **kwargs)
return pretrain(args, outputdir, {'nlayers':4, 'dropout':0.2, 'reluslope':0.0,
'nepoch':nepoch, 'lrate':[args.lr], 'wdecay':[0.0], 'step':step}, use_cuda, trainloader, testloader, logger)
示例2: test_smoke_logger
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def test_smoke_logger(tmpdir):
logger = Logger(str(tmpdir), flush_secs=0.1)
for step in range(10):
logger.log_value('v1', step * 1.5, step)
logger.log_value('v2', step ** 1.5 - 2)
time.sleep(0.5)
tf_log, = tmpdir.listdir()
assert tf_log.basename.startswith('events.out.tfevents.')
示例3: test_serialization
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def test_serialization(tmpdir):
logger = Logger(str(tmpdir), flush_secs=0.1, dummy_time=256.5)
logger.log_value('v/1', 1.5, 1)
logger.log_value('v/22', 16.0, 2)
time.sleep(0.5)
tf_log, = tmpdir.listdir()
assert tf_log.read_binary() == (
# step = 0, initial record
b'\x18\x00\x00\x00\x00\x00\x00\x00\xa3\x7fK"\t\x00\x00\x00\x00\x00\x08p@\x1a\rbrain.Event:2\xbc\x98!+'
# v/1
b'\x19\x00\x00\x00\x00\x00\x00\x00\x8b\xf1\x08(\t\x00\x00\x00\x00\x00\x08p@\x10\x01*\x0c\n\n\n\x03v/1\x15\x00\x00\xc0?,\xec\xc0\x87'
# v/22
b'\x1a\x00\x00\x00\x00\x00\x00\x00\x12\x9b\xd8-\t\x00\x00\x00\x00\x00\x08p@\x10\x02*\r\n\x0b\n\x04v/22\x15\x00\x00\x80A\x8f\xa3\xb6\x88'
)
示例4: test_dummy
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def test_dummy():
logger = Logger(None, is_dummy=True)
for step in range(3):
logger.log_value('A v/1', step, step)
logger.log_value('A v/2', step * 2, step)
assert dict(logger.dummy_log) == {
'A_v/1': [(0, 0), (1, 1), (2, 2)],
'A_v/2': [(0, 0), (1, 2), (2, 4)],
}
示例5: test_unique
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def test_unique():
logger = Logger(None, is_dummy=True)
for step in range(1, 3):
# names that normalize to the same valid name
logger.log_value('A v/1', step, step)
logger.log_value('A\tv/1', step * 2, step)
logger.log_value('A v/1', step * 3, step)
assert dict(logger.dummy_log) == {
'A_v/1': [(1, 1), (2, 2)],
'A_v/1/1': [(1, 2), (2, 4)],
'A_v/1/2': [(1, 3), (2, 6)],
}
示例6: test_dummy_histo
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def test_dummy_histo():
logger = Logger(None, is_dummy=True)
bins = [0, 1, 2, 3]
logger.log_histogram('key', (bins, [0.0, 1.0, 2.0]), step=1)
logger.log_histogram('key', (bins, [1.0, 1.5, 2.5]), step=2)
logger.log_histogram('key', (bins, [0.0, 1.0, 2.0]), step=3)
assert dict(logger.dummy_log) == {
'key': [(1, (bins, [0.0, 1.0, 2.0])),
(2, (bins, [1.0, 1.5, 2.5])),
(3, (bins, [0.0, 1.0, 2.0]))]}
示例7: test_real_histo_data
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def test_real_histo_data(tmpdir):
logger = Logger(str(tmpdir), flush_secs=0.1)
logger.log_histogram('hist2', [1, 7, 6, 9, 8, 1, 4, 5, 3, 7], step=1)
logger.log_histogram('hist2', [5, 3, 2, 0, 8, 5, 7, 7, 7, 2], step=2)
logger.log_histogram('hist2', [1, 2, 2, 1, 5, 1, 8, 4, 4, 1], step=3)
tf_log, = glob.glob(str(tmpdir) + '/*')
assert os.path.basename(tf_log).startswith('events.out.tfevents.')
示例8: test_dummy_images
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def test_dummy_images():
logger = Logger(None, is_dummy=True)
img = np.random.rand(10, 10)
images = [img, img]
logger.log_images('key', images, step=1)
logger.log_images('key', images, step=2)
logger.log_images('key', images, step=3)
assert dict(logger.dummy_log) == {
'key': [(1, images),
(2, images),
(3, images)]}
示例9: test_real_image_data
# 需要導入模塊: import tensorboard_logger [as 別名]
# 或者: from tensorboard_logger import Logger [as 別名]
def test_real_image_data(tmpdir):
logger = Logger(str(tmpdir), flush_secs=0.1)
img = np.random.rand(10, 10)
images = [img, img]
logger.log_images('key', images, step=1)
logger.log_images('key', images, step=2)
logger.log_images('key', images, step=3)
tf_log, = glob.glob(str(tmpdir) + '/*')
assert os.path.basename(tf_log).startswith('events.out.tfevents.')