首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Lasange图像缩放的卷积网络

使用Lasange图像缩放的卷积网络
EN

Stack Overflow用户
提问于 2015-09-17 19:06:05
回答 1查看 412关注 0票数 1

我一直在使用Lasagne训练一些神经网络和卷积网络,并使用Python进行大部分数据/图像预处理。然而,我想将其中的一些整合到我的千层面层中,使我的代码更加灵活。

有没有可以调整输入图像大小的千层面?

EN

回答 1

Stack Overflow用户

发布于 2015-09-17 19:13:21

您可以使用nolearn.lasagne.BatchIterator,而不是在层中执行此操作;在以下代码片段中,我将原始的1D信号重采样为1000点信号:

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32628838

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档