π The CoCalc Library - books, templates and other resources
License: OTHER
Credits: Forked from deep-learning-keras-tensorflow by Valerio Maggio
Theano
A language in a language
Dealing with weights matrices and gradients can be tricky and sometimes not trivial. Theano is a great framework for handling vectors, matrices and high dimensional tensor algebra. Most of this tutorial will refer to Theano however TensorFlow is another great framework capable of providing an incredible abstraction for complex algebra. More on TensorFlow in the next chapters.
Symbolic variables
Theano has it's own variables and functions, defined the following
Variables can be used in expressions
y is an expression now
Result is symbolic as well
#####printing
As we are about to see, normal printing isn't the best when it comes to theano
Evaluating expressions
Supply a dict
mapping variables to values
Or compile a function
Other tensor types
Automatic differention
Gradients are free!
Shared Variables
Symbolic + Storage
We can get and set the variable's value
Shared variables can be used in expressions as well
Their value is used as input when evaluating
Updates
Store results of function evalution
dict
mapping shared variables to new values
Warming up! Logistic Regression
For this section we will use the Kaggle otto challenge. If you want to follow, Get the data from Kaggle: https://www.kaggle.com/c/otto-group-product-classification-challenge/data
About the data
The Otto Group is one of the worldβs biggest e-commerce companies, A consistent analysis of the performance of products is crucial. However, due to diverse global infrastructure, many identical products get classified differently. For this competition, we have provided a dataset with 93 features for more than 200,000 products. The objective is to build a predictive model which is able to distinguish between our main product categories. Each row corresponds to a single product. There are a total of 93 numerical features, which represent counts of different events. All features have been obfuscated and will not be defined any further.
https://www.kaggle.com/c/otto-group-product-classification-challenge/data
Now lets create and train a logistic regression model.