Skip to content

add helper scripts to use LeNet model against MNIST data#1018

Closed
lelayf wants to merge 3 commits intoBVLC:devfrom
crossgradient:add-mnist-prediction-example
Closed

add helper scripts to use LeNet model against MNIST data#1018
lelayf wants to merge 3 commits intoBVLC:devfrom
crossgradient:add-mnist-prediction-example

Conversation

@lelayf
Copy link

@lelayf lelayf commented Aug 31, 2014

This is taking over PR #1017 to target BVLC:dev branch instead of BVLC:master.

@sergeyk
Copy link
Contributor

sergeyk commented Sep 5, 2014

This looks good to me.

@shelhamer
Copy link
Member

@lelayf thanks for the helper scripts to improve the LeNet example. Please take a look at #959 and the IPython notebook there. It has simple code for loading the MNIST digits and labels that you could integrate here.

TEST_DATA_FILE = '../../data/mnist/t10k-images-idx3-ubyte'
TEST_LABEL_FILE = '../../data/mnist/t10k-labels-idx1-ubyte'
n = 10000

with open(TEST_DATA_FILE, 'rb') as f:
    f.read(16) # skip the header
    images = np.fromstring(f.read(n * 28*28), dtype=np.uint8)
images = images.reshape(n, 28*28)

with open(TEST_LABEL_FILE, 'rb') as f:
    f.read(8) # skip the header
    labels = np.fromstring(f.read(n), dtype=np.uint8)

# scale and reshape
images = images.reshape(n, 1, 28, 28).astype(np.float32) / 255.   

add numpy formatting option to display entire array (read_npy)
@lelayf
Copy link
Author

lelayf commented Sep 7, 2014

@shelhamer I checked the IPython notebook you mentioned and changed the way I read those bytes to something hopefully more expressive. Depending on exceptions that are raised at runtime, the reader might return the expected arrays or nothing. For the current purpose it seems fine but if you'd rather see less indentation of the return statement to return None,None in case of failure then I can make the change.

@shelhamer
Copy link
Member

Thanks for the helper scripts, and for switching the base of your PR for our workflow at the time, but in the end dev was deprecated for a single branch workflow so I'm closing this PR.

Improvements to our examples and documentation are of course always welcome in master.

@shelhamer shelhamer closed this Aug 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments