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


Python tensorboard_logger.Logger方法代码示例

本文整理汇总了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) 
开发者ID:shahsohil,项目名称:DCC,代码行数:40,代码来源:pretraining.py

示例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.') 
开发者ID:TeamHG-Memex,项目名称:tensorboard_logger,代码行数:10,代码来源:test_tensorboard_logger.py

示例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'
    ) 
开发者ID:TeamHG-Memex,项目名称:tensorboard_logger,代码行数:16,代码来源:test_tensorboard_logger.py

示例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)],
    } 
开发者ID:TeamHG-Memex,项目名称:tensorboard_logger,代码行数:11,代码来源:test_tensorboard_logger.py

示例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)],
    } 
开发者ID:TeamHG-Memex,项目名称:tensorboard_logger,代码行数:14,代码来源:test_tensorboard_logger.py

示例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]))]} 
开发者ID:TeamHG-Memex,项目名称:tensorboard_logger,代码行数:13,代码来源:test_tensorboard_logger.py

示例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.') 
开发者ID:TeamHG-Memex,项目名称:tensorboard_logger,代码行数:9,代码来源:test_tensorboard_logger.py

示例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)]} 
开发者ID:TeamHG-Memex,项目名称:tensorboard_logger,代码行数:14,代码来源:test_tensorboard_logger.py

示例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.') 
开发者ID:TeamHG-Memex,项目名称:tensorboard_logger,代码行数:11,代码来源:test_tensorboard_logger.py


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