【问题标题】:Getting the learned representation of the data from the unsupervised learning in pylearn2从 pylearn2 中的无监督学习中获取数据的学习表示
【发布时间】:2014-11-15 17:43:53
【问题描述】:

我们可以使用下面的 YAML 文件(以及 pylearn2/scripts/train.py)在 pylearn2 中训练自动编码器

!obj:pylearn2.train.Train {
    dataset: &train !obj:pylearn2.datasets.mnist.MNIST {
        which_set: 'train',
        start: 0,
        stop: 50000
    },
    model: !obj:pylearn2.models.autoencoder.DenoisingAutoencoder {
        nvis : 784,
        nhid : 500,
        irange : 0.05,
        corruptor: !obj:pylearn2.corruption.BinomialCorruptor {
            corruption_level: .2,
        },
        act_enc: "tanh",
        act_dec: null,    # Linear activation on the decoder side.
    },
    algorithm: !obj:pylearn2.training_algorithms.sgd.SGD {
        learning_rate : 1e-3,
        batch_size : 100,
        monitoring_batches : 5,
        monitoring_dataset : *train,
        cost : !obj:pylearn2.costs.autoencoder.MeanSquaredReconstructionError {},
        termination_criterion : !obj:pylearn2.termination_criteria.EpochCounter {
            max_epochs: 10,
        },
    },
    save_path: "./dae_l1.pkl",
    save_freq: 1
}

我们得到的是学习到的自动编码器模型“dae_l1.pkl”。

如果我想将此模型用于监督训练,我可以使用“dae_l1.pkl”来初始化 MLP 的层。然后我可以训练这个模型。 我什至可以使用“fprop”函数预测模型的输出。

但是,如果我不想使用这个预训练模型进行监督学习,我只想使用自动编码器保存我的数据的新学习表示。

我该怎么做?

更详细的问题放在here

【问题讨论】:

    标签: python yaml theano unsupervised-learning autoencoder


    【解决方案1】:

    腌制模型的reconstruct方法应该可以做到——我相信用法和fprop一样。

    【讨论】:

      【解决方案2】:

      我认为您可以使用自动编码器的编码和解码功能来获取隐藏表示。例如:

      l1_path = 'dae_l1.pkl'
      l1 = serial.load(l1_path)
      """encode"""
      #layer 1
      l1Input = l1.get_input_space().make_theano_batch()
      l1Encode = l1.encode(l1Input)
      l1Decode = l1.decode(l1Encode)
      l1EncodeFunction = theano.function([l1Input], l1Encode)
      l1DecodeFunction = theano.function([l1Encode], l1Decode)
      

      然后,表示将是:

      l1encode = l1EncodeFunction(YourData)
      

      【讨论】:

        猜你喜欢
        • 2014-04-20
        • 2013-03-24
        • 2017-08-11
        • 2019-02-20
        • 2021-10-17
        • 2018-10-01
        • 2017-06-27
        • 2010-12-22
        • 2019-04-16
        相关资源
        最近更新 更多