jatinshah / ufldl_tutorial Goto Github PK
View Code? Open in Web Editor NEWStanford Unsupervised Feature Learning and Deep Learning Tutorial
License: MIT License
Stanford Unsupervised Feature Learning and Deep Learning Tutorial
License: MIT License
In calculating the gradient, you only consider take derivatives to the z2, but not taking the sparsity loss into consideration.
You should add a np.sqrt above s+epsilon like below.
(u, s, vt) = np.linalg.svd(sigma)
zca_white = u.dot(np.diag(1 / np.sqrt(s + epsilon))).dot(u.transpose())
dad's kiiiii
File "........\load_MNIST.py", line 18, in load_MNIST_images
images = images.reshape((num_images, num_rows * num_cols)).transpose()
ValueError: total size of new array must be unchanged
when I run the train.py,I get the following error
images = images.reshape((num_images[0], num_rows[0] * num_cols[0])).transpose()
Traceback (most recent call last):
File "/home/snow/Documents/study/ufldl_tutorial/train.py", line 42, in
images = load_MNIST.load_MNIST_images('data/mnist/train-images-idx3-ubyte')
File "/home/snow/Documents/study/ufldl_tutorial/load_MNIST.py", line 20, in load_MNIST_images
images = images.reshape((num_images[0], num_rows[0] * num_cols[0])).transpose()
ValueError: cannot reshape array of size 9912406 into shape (2055376946,1902539786)
#####code begin
with open(filename, "rb") as f:
magic = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
num_images = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
num_rows = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
num_cols = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
#num_images = 60000
#num_rows = 28
#num_cols = 28
images = np.fromfile(f, dtype=np.ubyte)
images = images.reshape((num_images[0], num_rows[0] * num_cols[0])).transpose()
images = images.astype(np.float64) / 255
f.close()
#####code end
I google the http://yann.lecun.com/exdb/mnist/
find the value:
0004 32 bit integer 60000 number of images
0008 32 bit integer 28 number of rows
0012 32 bit integer 28 number of columns
by calculating the value, I find 282860000 larger than the 9912422,that makes me so confused,
How can I correct the code?
Hi guys,,
have you the problem of terrified slow computation when run the line
num_grad = gradient.compute_gradient(J, theta) % line 101 in train.py
It has already taken more than 12 hours and only finished 34700 inputs.
Do I run the code not in a right way? Thanks
Matlab mnist images are stored column major order, whereas this version stores them in row major. This means that when transferring weights between Python and Matlab implementations, you need to reshape/transpose/flatten each row of the first layer weights matrix
I modified train.py like this to do sample image exercise:
"
visible_size = 8 * 8
hidden_size = 25
......
patches = sample_images.sample_images()
"
but I got wrong output, any suggestion? Thank you!
I also tried
"
sparsity_param = 0.01
lambda_ = 1e-3
beta = 3
"
like what ufldl tutorial suggested, but the output is still wrong!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.