材料收集、整理、学习、汇总
参考链接:
https://blog.csdn.net/mingtian715/article/details/54628950
Theano深度学习笔记(二)逻辑回归对MNIST分类
https://blog.csdn.net/Yt7589/article/details/52185504?locationNum=7
深度学习算法实践9---用Theano实现多层前馈网络
http://deeplearning.net/tutorial/mlp.html#mlp
Multilayer Perceptron
https://blog.csdn.net/u012162613/article/details/43221829
DeepLearning tutorial(3)MLP多层感知机原理简介+代码详解
https://blog.csdn.net/u013007900/article/details/52439172
theano学习初步(一)
https://cloud.tencent.com/developer/article/1064630
利用Theano理解深度学习——Logistic Regression
http://deeplearning.net/software/theano/tutorial/adding.html#baby-steps-algebra
theano官方文档
#-*- coding:utf-8 -*-
__author__ = 'changqing'
"""
This tutorial introduces logistic regression using Theano and stochastic
gradient descent.
Logistic regression is a probabilistic, linear classifier. It is parametrized
by a weight matrix :math:`W` and a bias vector :math:`b`. Classification is
done by projecting data points onto a set of hyperplanes, the distance to
which is used to determine a class membership probability.
Mathematically, this can be written as:
.. math::
P(Y=i|x, W,b) &= softmax_i(W x + b) \\
&= \frac {e^{W_i x + b_i}} {\sum_j e^{W_j x + b_j}}
The output of the model or prediction is then done by taking the argmax of
the vector whose i'th element is P(Y=i|x).
.. math::
y_{pred} = argmax_i P(Y=i|x,W,b)
This tutorial presents a stochastic gradient descent optimization method
suitable for large datasets.
References:
- textbooks: "Pattern Recognition and Machine Learning" -
Christopher M. Bishop, section 4.3.2
"""
#from __future__ import print_function
__docformat__ = 'restructedtext en'
import six.moves.cPickle as pickle
import gzip
import os
import sys
import timeit
import numpy
###深度学习的维度转换
import theano
import theano.tensor as T
###参考链接https://blog.csdn.net/mingtian715/article/details/54628950
class LogisticRegression(object):
"""Multi-class Logistic Regression Class
The logistic regression is fully described by a weight matrix :math:`W`
and bias vector :math:`b`. Classification is done by projecting data
points onto a set of hyperplanes, the distance to which is used to
determine a class membership probability.
"""
def __init__(self, input, n_in, n_out):
""" Initialize the parameters of the logistic regression
:type input: theano.tensor.TensorType
:param input: symbolic variable that describes the input of the
architecture (one minibatch)
:type n_in: int
:param n_in: number of input units, the dimension of the space in
which the datapoints lie
:type n_out: int
:param n_out: number of output units, the dimension of the space in
which the labels lie
"""
# start-snippet-1
# initialize with 0 the weights W as a matrix of shape (n_in, n_out)
self.W = theano.shared(
value=numpy.zeros(
(n_in, n_out),
dtype=theano.config.floatX
),
name='W',
borrow=True
)
# initialize the biases b as a vector of n_out 0s
self.b =