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


Python serializers.save_hdf5方法代碼示例

本文整理匯總了Python中chainer.serializers.save_hdf5方法的典型用法代碼示例。如果您正苦於以下問題:Python serializers.save_hdf5方法的具體用法?Python serializers.save_hdf5怎麽用?Python serializers.save_hdf5使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在chainer.serializers的用法示例。


在下文中一共展示了serializers.save_hdf5方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: save_model

# 需要導入模塊: from chainer import serializers [as 別名]
# 或者: from chainer.serializers import save_hdf5 [as 別名]
def save_model(self, model_filename):
        """Save a network model to a file
        """
        serializers.save_hdf5(model_filename, self.model)
        serializers.save_hdf5(model_filename + '.opt', self.optimizer) 
開發者ID:muupan,項目名稱:async-rl,代碼行數:7,代碼來源:a3c.py

示例2: save_and_load_hdf5

# 需要導入模塊: from chainer import serializers [as 別名]
# 或者: from chainer.serializers import save_hdf5 [as 別名]
def save_and_load_hdf5(src, dst):
    """Saves ``src`` to an HDF5 file and loads it to ``dst``.

    This is a short cut of :func:`save_and_load` using HDF5 de/serializers.

    Args:
        src: An object to save.
        dst: An object to load to.

    """
    save_and_load(src, dst, 'tmp.h5',
                  serializers.save_hdf5, serializers.load_hdf5) 
開發者ID:chainer,項目名稱:chainer,代碼行數:14,代碼來源:serializer.py

示例3: save

# 需要導入模塊: from chainer import serializers [as 別名]
# 或者: from chainer.serializers import save_hdf5 [as 別名]
def save(self):
		serializers.save_hdf5("conv.model", self.conv)
		if self.fcl_eliminated is False:
			serializers.save_hdf5("fc.model", self.fc) 
開發者ID:musyoku,項目名稱:double-dqn,代碼行數:6,代碼來源:ddqn.py

示例4: save

# 需要導入模塊: from chainer import serializers [as 別名]
# 或者: from chainer.serializers import save_hdf5 [as 別名]
def save(self,filename):
		cs.save_hdf5(filename,self.func.copy().to_cpu()) 
開發者ID:uei,項目名稱:deel,代碼行數:4,代碼來源:nin.py

示例5: save

# 需要導入模塊: from chainer import serializers [as 別名]
# 或者: from chainer.serializers import save_hdf5 [as 別名]
def save(self,filename):
		cs.save_hdf5(filename,self.model.copy().to_cpu()) 
開發者ID:uei,項目名稱:deel,代碼行數:4,代碼來源:googlenet.py

示例6: save

# 需要導入模塊: from chainer import serializers [as 別名]
# 或者: from chainer.serializers import save_hdf5 [as 別名]
def save(self,filename):
		#cs.save_hdf5(filename,self.func.copy().to_cpu())
		cs.save_hdf5(filename,self.func.copy()) 
開發者ID:uei,項目名稱:deel,代碼行數:5,代碼來源:rnin.py

示例7: save

# 需要導入模塊: from chainer import serializers [as 別名]
# 或者: from chainer.serializers import save_hdf5 [as 別名]
def save(self,filename):
		cs.save_hdf5(filename,self.func.to_cpu()) 
開發者ID:uei,項目名稱:deel,代碼行數:4,代碼來源:resnet152.py

示例8: train

# 需要導入模塊: from chainer import serializers [as 別名]
# 或者: from chainer.serializers import save_hdf5 [as 別名]
def train(epoch_num):
    image_groups, sentence_groups = make_groups(train_image_ids, train_sentences)
    test_image_groups, test_sentence_groups = make_groups(test_image_ids, test_sentences, train=False)
    for epoch in range(epoch_num):
        batches = random_batches(image_groups, sentence_groups)
        sum_loss = 0
        sum_acc = 0
        sum_size = 0
        batch_num = len(batches)
        for i, (image_id_batch, sentence_batch) in enumerate(batches):
            loss, acc, size = forward(caption_net, images[image_id_batch], sentence_batch)
            caption_net.cleargrads()
            loss.backward()
            loss.unchain_backward()
            optimizer.update()
            sentence_length = sentence_batch.shape[1]
            sum_loss += float(loss.data) * size
            sum_acc += acc * size
            sum_size += size
            if (i + 1) % 500 == 0:
                print '{} / {} loss: {} accuracy: {}'.format(i + 1, batch_num, sum_loss / sum_size, sum_acc / sum_size)
        print 'epoch: {} done'.format(epoch + 1)
        print 'train loss: {} accuracy: {}'.format(sum_loss / sum_size, sum_acc / sum_size)
        sum_loss = 0
        sum_acc = 0
        sum_size = 0
        for image_ids, sentences in zip(test_image_groups, test_sentence_groups):
            if len(sentences) == 0:
                continue
            size = len(sentences)
            for i in range(0, size, batch_size):
                image_id_batch = image_ids[i:i + batch_size]
                sentence_batch = sentences[i:i + batch_size]
                loss, acc, size = forward(caption_net, images[image_id_batch], sentence_batch, train=False)
                sentence_length = sentence_batch.shape[1]
                sum_loss += float(loss.data) * size
                sum_acc += acc * size
                sum_size += size
        print 'test loss: {} accuracy: {}'.format(sum_loss / sum_size, sum_acc / sum_size)

        serializers.save_hdf5(args.output + '_{0:04d}.model'.format(epoch), caption_net)
        serializers.save_hdf5(args.output + '_{0:04d}.state'.format(epoch), optimizer) 
開發者ID:dsanno,項目名稱:chainer-image-caption,代碼行數:44,代碼來源:train.py


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