Giter Site home page Giter Site logo

mnist_tsne's Introduction

mnist_tsne

t-sne visualization of mnist images when feature is represented by raw pixels and cnn learned feature

something to say

  • the training code is from pytorch mnist example. The accuracy is 98% when use the original code, when bn is used in convolution and fully connected layer, the accuracy is 99. The training code here is with bn.
  • the code for t-sne visualization is from danielfrg/tsne
  • you can find the original mnist train raw data(60000x784), lable(60000x1), cnn learned feature(60000x50), t-sne generated feature(60000x2) for raw data and cnn learned feature, trained model in Baidu Pan or Google Drive
  • tsne_vis.ipynb is used to do tsne and visualization

visualization

t-sne of raw image pixel t-sne of cnn learned feature

from above visualization, it is shown that t-sne of cnn learned feature is more centered and cleaner than that of t-sne of raw image pixel

mnist_tsne's People

Contributors

animebing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mnist_tsne's Issues

Error

Hi,
Thank you for this code.

I got the following error during tsne_vis.ipynb. Can you please help me to sort out?


TypeError Traceback (most recent call last)
~/pytorch_new_python3/lib/python3.5/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
173 try:
--> 174 rgba = _colors_full_map.cache[c, alpha]
175 except (KeyError, TypeError): # Not in cache, or unhashable.

TypeError: unhashable type: 'numpy.ndarray'

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
~/pytorch_new_python3/lib/python3.5/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
4231 try: # Then is 'c' acceptable as PathCollection facecolors?
-> 4232 colors = mcolors.to_rgba_array(c)
4233 n_elem = colors.shape[0]

~/pytorch_new_python3/lib/python3.5/site-packages/matplotlib/colors.py in to_rgba_array(c, alpha)
274 for i, cc in enumerate(c):
--> 275 result[i] = to_rgba(cc, alpha)
276 return result

~/pytorch_new_python3/lib/python3.5/site-packages/matplotlib/colors.py in to_rgba(c, alpha)
175 except (KeyError, TypeError): # Not in cache, or unhashable.
--> 176 rgba = _to_rgba_no_colorcycle(c, alpha)
177 try:

~/pytorch_new_python3/lib/python3.5/site-packages/matplotlib/colors.py in _to_rgba_no_colorcycle(c, alpha)
230 if len(c) not in [3, 4]:
--> 231 raise ValueError("RGBA sequence should have length 3 or 4")
232 if len(c) == 3 and alpha is None:

ValueError: RGBA sequence should have length 3 or 4

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
in
1 plt.rcParams['figure.figsize'] = 20, 20
----> 2 plt.scatter(output_2d[:, 0], output_2d[:, 1], c=target)
3 plt.savefig('train/output_2d.png', bbox_inches='tight')
4 plt.show()

~/pytorch_new_python3/lib/python3.5/site-packages/matplotlib/pyplot.py in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, data, **kwargs)
2862 vmin=vmin, vmax=vmax, alpha=alpha, linewidths=linewidths,
2863 verts=verts, edgecolors=edgecolors, **({"data": data} if data
-> 2864 is not None else {}), **kwargs)
2865 sci(__ret)
2866 return __ret

~/pytorch_new_python3/lib/python3.5/site-packages/matplotlib/init.py in inner(ax, data, *args, **kwargs)
1808 "the Matplotlib list!)" % (label_namer, func.name),
1809 RuntimeWarning, stacklevel=2)
-> 1810 return func(ax, *args, **kwargs)
1811
1812 inner.doc = _add_data_doc(inner.doc,

~/pytorch_new_python3/lib/python3.5/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
4243 "acceptable for use with 'x' with size {xs}, "
4244 "'y' with size {ys}."
-> 4245 .format(nc=n_elem, xs=x.size, ys=y.size)
4246 )
4247 # Both the mapping and the RGBA conversion failed: pretty

ValueError: 'c' argument has 60000 elements, which is not acceptable for use with 'x' with size 60000, 'y' with size 60000.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.