【发布时间】:2015-12-14 05:38:02
【问题描述】:
我一直在使用 Lasagne 训练一些神经网络和卷积网络,并使用 Python 进行大部分数据/图像预处理。但是,我想将其中的一些合并到我的千层面层中,以使我的代码更加灵活。
是否有可以调整输入图像大小的千层面层?
【问题讨论】:
标签: python image-processing neural-network theano lasagne
我一直在使用 Lasagne 训练一些神经网络和卷积网络,并使用 Python 进行大部分数据/图像预处理。但是,我想将其中的一些合并到我的千层面层中,以使我的代码更加灵活。
是否有可以调整输入图像大小的千层面层?
【问题讨论】:
标签: python image-processing neural-network theano lasagne
您可以使用nolearn.lasagne.BatchIterator,而不是在层中执行此操作;在下面的 sn-p 中,我将原始 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
【讨论】: