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


Python sugartensor.sg_info方法代码示例

本文整理汇总了Python中sugartensor.sg_info方法的典型用法代码示例。如果您正苦于以下问题:Python sugartensor.sg_info方法的具体用法?Python sugartensor.sg_info怎么用?Python sugartensor.sg_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sugartensor的用法示例。


在下文中一共展示了sugartensor.sg_info方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import sugartensor [as 别名]
# 或者: from sugartensor import sg_info [as 别名]
def __init__(self, batch_size=32, name='train'):

        # load train corpus
        sources, targets = self._load_corpus(mode='train')

        # to constant tensor
        source = tf.convert_to_tensor(sources)
        target = tf.convert_to_tensor(targets)

        # create queue from constant tensor
        source, target = tf.train.slice_input_producer([source, target])

        # create batch queue
        batch_queue = tf.train.shuffle_batch([source, target], batch_size,
                                             num_threads=32, capacity=batch_size*64,
                                             min_after_dequeue=batch_size*32, name=name)

        # split data
        self.source, self.target = batch_queue

        # calc total batch count
        self.num_batch = len(sources) // batch_size

        # print info
        tf.sg_info('Train data loaded.(total data=%d, total batch=%d)' % (len(sources), self.num_batch)) 
开发者ID:buriburisuri,项目名称:ByteNet,代码行数:27,代码来源:data.py

示例2: run_generator

# 需要导入模块: import sugartensor [as 别名]
# 或者: from sugartensor import sg_info [as 别名]
def run_generator(num, x1, x2, fig_name='sample.png'):
    with tf.Session() as sess:

        tf.sg_init(sess)

        # restore parameters
        tf.sg_restore(sess, tf.train.latest_checkpoint('asset/train/infogan'), category='generator')

        # run generator
        imgs = sess.run(gen, {target_num: num,
                              target_cval_1: x1,
                              target_cval_2: x2})

        # plot result
        _, ax = plt.subplots(10, 10, sharex=True, sharey=True)
        for i in range(10):
            for j in range(10):
                ax[i][j].imshow(imgs[i * 10 + j], 'gray')
                ax[i][j].set_axis_off()
        plt.savefig('asset/train/infogan/' + fig_name, dpi=600)
        tf.sg_info('Sample image saved to "asset/train/infogan/%s"' % fig_name)
        plt.close()


#
# draw sample by categorical division
#

# fake image 
开发者ID:buriburisuri,项目名称:sugartensor,代码行数:31,代码来源:mnist_info_gan_eval.py

示例3: run_generator

# 需要导入模块: import sugartensor [as 别名]
# 或者: from sugartensor import sg_info [as 别名]
def run_generator(num, x1, x2, fig_name='sample.png'):
    with tf.Session() as sess:
        tf.sg_init(sess)
        # restore parameters
        saver = tf.train.Saver()
        saver.restore(sess, tf.train.latest_checkpoint('asset/train'))

        # run generator
        imgs = sess.run(gen, {target_num: num,
                              target_cval_1: x1,
                              target_cval_2: x2})

        # plot result
        _, ax = plt.subplots(10, 10, sharex=True, sharey=True)
        for i in range(10):
            for j in range(10):
                ax[i][j].imshow(imgs[i * 10 + j], 'gray')
                ax[i][j].set_axis_off()
        plt.savefig('asset/train/' + fig_name, dpi=600)
        tf.sg_info('Sample image saved to "asset/train/%s"' % fig_name)
        plt.close()


#
# draw sample by categorical division
#

# fake image 
开发者ID:buriburisuri,项目名称:ac-gan,代码行数:30,代码来源:generate.py

示例4: __init__

# 需要导入模块: import sugartensor [as 别名]
# 或者: from sugartensor import sg_info [as 别名]
def __init__(self, batch_size=16, set_name='train'):

        # load meta file
        label, mfcc_file = [], []
        with open(_data_path + 'preprocess/meta/%s.csv' % set_name) as csv_file:
            reader = csv.reader(csv_file, delimiter=',')
            for row in reader:
                # mfcc file
                mfcc_file.append(_data_path + 'preprocess/mfcc/' + row[0] + '.npy')
                # label info ( convert to string object for variable-length support )
                label.append(np.asarray(row[1:], dtype=np.int).tostring())

        # to constant tensor
        label_t = tf.convert_to_tensor(label)
        mfcc_file_t = tf.convert_to_tensor(mfcc_file)

        # create queue from constant tensor
        label_q, mfcc_file_q \
            = tf.train.slice_input_producer([label_t, mfcc_file_t], shuffle=True)

        # create label, mfcc queue
        label_q, mfcc_q = _load_mfcc(source=[label_q, mfcc_file_q],
                                     dtypes=[tf.sg_intx, tf.sg_floatx],
                                     capacity=256, num_threads=64)

        # create batch queue with dynamic pad
        batch_queue = tf.train.batch([label_q, mfcc_q], batch_size,
                                     shapes=[(None,), (20, None)],
                                     num_threads=64, capacity=batch_size*32,
                                     dynamic_pad=True)

        # split data
        self.label, self.mfcc = batch_queue
        # batch * time * dim
        self.mfcc = self.mfcc.sg_transpose(perm=[0, 2, 1])
        # calc total batch count
        self.num_batch = len(label) // batch_size

        # print info
        tf.sg_info('%s set loaded.(total data=%d, total batch=%d)'
                   % (set_name.upper(), len(label), self.num_batch)) 
开发者ID:buriburisuri,项目名称:speech-to-text-wavenet,代码行数:43,代码来源:data.py

示例5: run_generator

# 需要导入模块: import sugartensor [as 别名]
# 或者: from sugartensor import sg_info [as 别名]
def run_generator(num, x1, x2, fig_name='sample.png'):
    with tf.Session() as sess:
        tf.sg_init(sess)
        # restore parameters
        saver = tf.train.Saver()
        saver.restore(sess, tf.train.latest_checkpoint('asset/train/ckpt'))

        # run generator
        imgs = sess.run(gen, {target_num: num,
                              target_cval_1: x1,
                              target_cval_2: x2})

        # plot result
        _, ax = plt.subplots(10, 10, sharex=True, sharey=True)
        for i in range(10):
            for j in range(10):
                ax[i][j].plot(imgs[i * 10 + j, :, 0], color='b', linewidth=0.25)
                # Turn off tick labels only
                # ax[i][j].set_axis_off()
                ax[i][j].set_xticks([])
                ax[i][j].set_yticks([])

        plt.savefig('asset/train/' + fig_name, dpi=600)
        tf.sg_info('Sample image saved to "asset/train/%s"' % fig_name)
        plt.close()


#
# draw sample by categorical division
#

# fake image 
开发者ID:jeanjerome,项目名称:semisupervised_timeseries_infogan,代码行数:34,代码来源:generate.py

示例6: run_generator

# 需要导入模块: import sugartensor [as 别名]
# 或者: from sugartensor import sg_info [as 别名]
def run_generator(num, x1, x2, fig_name='sample.png'):
    with tf.Session() as sess:
        tf.sg_init(sess)
        # restore parameters
        saver = tf.train.Saver()
        saver.restore(sess, tf.train.latest_checkpoint('asset/train/ckpt'))

        # run generator
        imgs = sess.run(gen, {target_num: num,
                              target_cval_1: x1,
                              target_cval_2: x2})

        # plot result
        _, ax = plt.subplots(10, 10, sharex=True, sharey=True)
        for i in range(10):
            for j in range(10):
                ax[i][j].plot(imgs[i * 10 + j, :, 0])
                ax[i][j].plot(imgs[i * 10 + j, :, 1])
                ax[i][j].set_axis_off()
        plt.savefig('asset/train/' + fig_name, dpi=600)
        tf.sg_info('Sample image saved to "asset/train/%s"' % fig_name)
        plt.close()


#
# draw sample by categorical division
#

# fake image 
开发者ID:buriburisuri,项目名称:timeseries_gan,代码行数:31,代码来源:generate.py

示例7: run_generator

# 需要导入模块: import sugartensor [as 别名]
# 或者: from sugartensor import sg_info [as 别名]
def run_generator(num, x1, x2, fig_name='sample.png'):
    with tf.Session() as sess:
        tf.sg_init(sess)
        # restore parameters
        saver = tf.train.Saver()
        saver.restore(sess, tf.train.latest_checkpoint('asset/train/ckpt'))

        # run generator
        imgs = sess.run(gen, {target_num: num,
                              target_cval_1: x1,
                              target_cval_2: x2})

        # plot result
        _, ax = plt.subplots(10, 10, sharex=True, sharey=True)
        for i in range(10):
            for j in range(10):
                ax[i][j].imshow(imgs[i * 10 + j], 'gray')
                ax[i][j].set_axis_off()
        plt.savefig('asset/train/' + fig_name, dpi=600)
        tf.sg_info('Sample image saved to "asset/train/%s"' % fig_name)
        plt.close()


#
# draw sample by categorical division
#

# fake image 
开发者ID:buriburisuri,项目名称:supervised_infogan,代码行数:30,代码来源:generate.py

示例8: sg_regularizer_loss

# 需要导入模块: import sugartensor [as 别名]
# 或者: from sugartensor import sg_info [as 别名]
def sg_regularizer_loss(scale=1.0):
    r""" Get regularizer losss

    Args:
      scale: A scalar. A weight applied to regularizer loss
    """
    return scale * tf.reduce_mean(tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES))

# Under construction
# def sg_tsne(tensor, meta_file='metadata.tsv', save_dir='asset/tsne'):
#     r""" Manages arguments of `tf.sg_opt`.
#
#     Args:
#         save_dir: A string. The root path to which checkpoint and log files are saved.
#           Default is `asset/train`.
#     """
#
#     # make directory if not exist
#     if not os.path.exists(save_dir):
#         os.makedirs(save_dir)
#
#     # checkpoint saver
#     saver = tf.train.Saver()
#
#     # summary writer
#     summary_writer = tf.summary.FileWriter(save_dir, graph=tf.get_default_graph())
#
#     # embedding visualizer
#     config = projector.ProjectorConfig()
#     emb = config.embeddings.add()
#     emb.tensor_name = tensor.name   # tensor
#     # emb.metadata_path = os.path.join(save_dir, meta_file)   # metadata file
#     projector.visualize_embeddings(summary_writer, config)
#
#     # create session
#     sess = tf.Session()
#     # initialize variables
#     sg_init(sess)
#
#     # save tsne
#     saver.save(sess, save_dir + '/model-tsne')
#
#     # logging
#     tf.sg_info('Tsne saved at %s' % (save_dir + '/model-tsne'))
#
#     # close session
#     sess.close() 
开发者ID:buriburisuri,项目名称:sugartensor,代码行数:49,代码来源:sg_train.py


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