How to know what kind of memory is stored in the connection weights? So, I have seen few pictures re-created by a Neural Network or some other Machine Learning algorithm after it has been trained over a data set.

How, exactly is this done? How are the weights converted back into a picture or a memory which a Neural Net is holding?

A real life example would be when we close our eyes we can easily visualize things we have seen. Based on that we can classify things we see. Now in a Neural Net classification part is easily done, but what about the visualization part? What does the Neural Net see when it closes its eyes? And how to represent it for human understanding?

For example a deep net generated this picture:


SOURCE: Deep nets generating stuff

There can be many other things generated. But the question is how exactly is this done?
You should use google for this question, it is extremely vague. Some technical documents will give very clear insight into what's happening here.

https://blog.openai.com/generative-models/

http://proceedings.mlr.press/v37/gregor15.pdf

If you really want to understand "what the AI is thinking", well, you may never know. The idea of AI is that it can handle complex data (high degree of dimensionality) and is too complex for Humans to comprehend.