我一直在使用Lasagne训练一些神经网络和卷积网络,并使用Python进行大部分数据/图像预处理。然而,我想将其中的一些整合到我的千层面层中,使我的代码更加灵活。
有没有可以调整输入图像大小的千层面?
发布于 2015-09-17 19:13:21
您可以使用nolearn.lasagne.BatchIterator,而不是在层中执行此操作;在以下代码片段中,我将原始的1D信号重采样为1000点信号:
from nolearn.lasagne import BatchIterator
from scipy.signal import resample
import numpy as np
class ResampleIterator(BatchIterator):
def __init__(self, batch_size, newSize):
super(ResampleIterator, self).__init__(batch_size)
self.newSize = newSize
def transform(self, Xb, yb):
X_new = resample(Xb, self.newSize, axis=2).astype(np.float32)
return X_new, yb
myNet = NeuralNet(
# define your usual other parameters (layers, etc) here
# and these are the lines you are interested in:
batch_iterator_train=CropIterator(batch_size=128, newSize=1000),
batch_iterator_test=CropIterator(batch_size=128, newSize=1000),
)我不知道你是否使用过nolearn,你可以阅读更多关于它的(安装,示例) here
https://stackoverflow.com/questions/32628838
复制相似问题