本文整理匯總了Python中pylearn2.base.Block.load方法的典型用法代碼示例。如果您正苦於以下問題:Python Block.load方法的具體用法?Python Block.load怎麽用?Python Block.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pylearn2.base.Block
的用法示例。
在下文中一共展示了Block.load方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: NotImplementedError
# 需要導入模塊: from pylearn2.base import Block [as 別名]
# 或者: from pylearn2.base.Block import load [as 別名]
# Set PCA subclass from argument.
if args.algorithm == 'cov_eig':
PCAImpl = CovEigPCA
elif args.algorithm == 'svd':
PCAImpl = SVDPCA
elif args.algorithm == 'online':
PCAImpl = OnlinePCA
conf['minibatch_size'] = args.minibatch_size
else:
# This should never happen.
raise NotImplementedError(args.algorithm)
# Load precomputed PCA transformation if requested; otherwise compute it.
if args.load_file:
pca = Block.load(args.load_file)
else:
print "... computing PCA"
pca = PCAImpl(**conf)
pca.train(train_data)
# Save the computed transformation.
pca.save(args.save_file)
# Apply the transformation to test and valid subsets.
inputs = tensor.matrix()
pca_transform = theano.function([inputs], pca(inputs))
valid_pca = pca_transform(valid_data)
test_pca = pca_transform(test_data)
print >> sys.stderr, "New shapes:", map(numpy.shape, [valid_pca, test_pca])
# TODO: Compute ALC here when the code using the labels is ready.