28F的茶水间和不远处的大裤衩：

## Theano tutorial: Theano Graphs Structures

#### graph structure

import theano.tensor as T
x = T.matrix('x')
y = T.matrix('y')
z = x + y


## Theano tutorial: A Real Example - Logistic Regression

import numpy
import theano
import theano.tensor as T
rng = numpy.random

N = 400
feats = 784
D = (rng.randn(N, feats), rng.randint(size=N,low=0, high=2))
training_steps = 10000

# Declare Theano symbolic variables
x = T.matrix("x")
y = T.vector("y")
w = theano.shared(rng.randn(feats), name="w")
b = theano.shared(0., name="b")
print "Initial model:"
print w.get_value(), b.get_value()

# Construct Theano expression graph
p_1 = 1 / (1 + T.exp(-T.dot(x, w) - b))   # Probability that target = 1
prediction = p_1 > 0.5                    # The prediction thresholded
xent = -y * T.log(p_1) - (1-y) * T.log(1-p_1) # Cross-entropy loss function
cost = xent.mean() + 0.01 * (w ** 2).sum()# The cost to minimize
gw,gb = T.grad(cost, [w, b])              # Compute the gradient of the cost
# following section of this tutorial)

# Compile
train = theano.function(
inputs=[x,y],
outputs=[prediction, xent],
updates=((w, w - 0.1 * gw), (b, b - 0.1 * gb)))
predict = theano.function(inputs=[x], outputs=prediction)

# Train
for i in range(training_steps):
pred, err = train(D[0], D[1])

print "Final model:"
print w.get_value(), b.get_value()
print "target values for D:", D[1]
print "prediction on D:", predict(D[0])


## Sparse Matrix

In this exercise you will practice basic C++ class construction, and memory allocation and deallocation. You are asked to implement a class that supports an extendable variant of a sparse matrix. A matrix is a two-dimensional array. A matrix is sparse when many positions in the array are not important. In usual sparse matrices entries are not important when they are 0. In our version of the saprse matrix we distinguish between existing positions and not existing positions. Existing positions in our sparse matrices could contain the entry 0. In both cases, allocating memory to the unimportant positions in the matrix is a waste of memory.

You could think about a database containing students and their grades in modules. Every row in the database corresponds to a student and every column corresponds to a module. Then, grades are to be stored only in modules that the student did take. The entry that corresponds to a module that the student did not take should not exist. In particular, 0 is a possible grade in a module that a student takes.
To summarize, you are going to implement a sparse matrix that stores integers (including 0) in some of the positions of a (relatively large) two-dimensional array.

Technically, I have created the header file for the sparse matrix. You have to complete it with additional members. You will have to submit two files: Sparse.cpp and Sparse.hpp. You will probably want to create your own main.cpp file that includes a program that actually executes your Sparse.cpp. You will not be submitting this file. I also supply a Makefile that you should (must) use for compilation. The Makefile includes a compilation of a main.cpp. The header file includes detailed descriptions of the functions that are required that you implement.

## 区间合并

[8, 12, 15, 17, 21, 27, 32, 34, 35, 36, 40, 60]
[0, 10, 18, 19, 23, 30, 31, 38, 43, 44]

[0, 12, 15, 17, 18, 19, 21, 30, 31, 38, 40, 60]

## 蓄水池抽样

#### 1. 在高德纳的TAoCP中有一个问题：

i = 1
while more input lines
with probability 1.0 / i++
choice = this input line
print choice


将第1个输入直接放到choice中

随机产生一个范围从1到i的整数r;
如果r == 1，令choice = 第i个输入