How does the model.predict() function work? - machine-learning

I am currently new to ML, and while going through one of the tutorials, I came across the model.predict() function. I have looked through the documentation of this function, but I want to know more about it, like how it works, the algorithm which it uses for prediction, etc.
Can anyone help please?

For a neural network based model, predict() performs forward propagation. It is describes in many books and blogs. See for instance this introduction, https://towardsdatascience.com/coding-neural-network-forward-propagation-and-backpropagtion-ccf8cf369f76
Convolutional Neural Networks and Recurrent Neural Networks use layers which have slight different forward functions.

Related

How to include input fatures in Recurrent Neural Networks

I want to predict a time series. I want to use methods like Recurrent Neural Networks (RNN) but I want to also have some other input features. I mean as far as I know RNN predicts the future just based on the history but I want to have other input feature besides historical data. I want to do something like regressor chain using RNN. I very much appreciate if anyone can give me some hints or examples doing what I explained.

Temporal Difference Learning and Back-propagation

I have read this page of standford - https://web.stanford.edu/group/pdplab/pdphandbook/handbookch10.html. I am not able to understand how TD learning is used in neural networks. I am trying to make a checkers AI which will use TD learning, similar to what they have implemented in backgammon. Please explain the working of TD Back-Propagation.
I have already referred this question - Neural Network and Temporal Difference Learning
But I am not able to understand the accepted answer. Please explain with a different approach if possible.
TD learning is not used in neural networks. Instead, neural networks are used in TD learning to store the value (or q-value) function.
I think that you are confusing backpropagation ( a neural networks' concept) with bootstrapping in RL. Bootstrapping uses a combination of recent information and previous estimations to generate new estimations.
When the state-space is large and it is not easy to store the value function in tables, neural networks are used as an approximation scheme to store the value function.
The discussion on forward/backward views is more about eligibility traces, etc. A case where RL bootstraps serval steps ahead in time. However, this is not practical and there are ways (such as eligibility traces) to leave a trail and update past states.
This should not be connected or confused with back propagation in neural networks. It has nothing to do with it.

Building a Tetris AI using Neuroevolution

I am planning to create a Tetris AI using artificial neural network and train it with genetic algorithm for a project in my high school computer science class. I have a basic understanding of how an ANN works and how to implement it with a genetic algorithm. I have already written a working Neural Network based on this tutorial and I'm currently working on a genetic algorithm.
My questions are:
Which GA model is better for this situation (Tetris), and why?
What should I use for input for the neural network? Because currently, the method I'm using is to simply convert the state of the board (the pieces) into a one dimensional array and feed it into the neural network? Is there a better approach?
What should the size (number of layers, neurons per layer) the neural network be?
Are there any good sources of information that can help me?
Thank you!
Similar task was already solved by Google, but they solved it for all kinds of Atari games - https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf.
Carefully read this article and all of the related articles too
This is a reinforcement learning task, in my opinion the hardest task in ML domain. So there will be no short answer for your questions - except that probably you shouldn't use GA heuristic at all and rely on reinforcements methods.

How to model a for loop in a neural network

I am currently in the process of learning neural networks and can understand basic examples like AND, OR, Addition, Multiplication, etc.
Right now, I am trying to build a neural network that takes two inputs x and n, and computes pow(x, n). And, this would require the neural network to have some form of a loop, and I am not sure how I can model a network with a loop
Can this sort of computation be modelled on a neural network? I am assuming it is possible.. based on the recently released paper(Neural Turing Machine), but not sure how. Any pointers on this would be very helpful.
Thanks!
Feedforward neural nets are not Turing-complete, and in particular they cannot model loops of arbitrary order. However, if you fix the maximum n that you want to treat, then you can set up an architecture which can model loops with up to n repetitions. For instance, you could easily imagine that each layer could act as one iteration in the loop, so you might need n layers.
For a more general architecture that can be made Turing-complete, you could use Recurrent Neural Networks (RNN). One popular instance in this class are the so-called Long short-term memory (LSTM) networks by Hochreiter and Schmidhuber. Training such RNNs is quite different from training classical feedforward networks, though.
As you pointed out, Neural Turing Machines seem to working well to learn the basic algorithms. For instance, the repeat copy task which has been implemented in the paper, might tell us that NTM can learn the algorithm itself. As of now, NTMs have been used only for simple tasks so understanding its scope by using the pow(x,n) will be interesting given that repeat copy works well. I suggest reading Reinforcement Learning Neural Turing Machines - Revised for a deeper understanding.
Also, recent developments in the area of Memory Networks empower us to perform more complicated tasks. Hence, to make a neural network understand pow(x,n) might be possible. So go ahead and give it a shot!

Convolutional Deep Belief Networks (CDBN) vs. Convolutional Neural Networks (CNN)

Lastly, I started to learn neural networks and I would like know the difference between Convolutional Deep Belief Networks and Convolutional Networks. In here, there is a similar question but there is no exact answer for it. We know that Convolutional Deep Belief Networks are CNNs + DBNs. So, I am going to do an object recognition. I want to know which one is much better than other or their complexity. I searched but I couldn't find anything maybe doing something wrong.
I don't know if you still need an answer but anyway I hope you will find this useful.
A CDBN adds the complexity of a DBN, but if you already have some background it's not that much.
If you are worried about computational complexity instead, it really depends on how you use the DBN part. The role of DBN usually is to initialize the weights of the network for faster convergence. In this scenario, the DBN appears only during pre-training.
You can also use the whole DBN like a discriminative network (keeping the generative power) but the weight initialization provided by it is enough for discriminative tasks. So during an hypothetical real-time utilization, the two system are equal performance-wise.
Also the weight-initialization provided by the first model anyway really helps for difficult task like object recognition (even a good Convolutional Neural network alone doesn't reach good success rate, at least compared to a human) so it's generally a good choice.

Resources