python

The python with statement is a little strange to programmers of other languages. It is frequently occurred in tensorflow related codes like: with tf.Session() as sess: do something A new […]

understand tensorflow graph

To understand tensorflow computation graph, you need to know how to print or plot it. If you can visualize the computation graph, it would be easy to understand it. The […]

import numpy as np X=2*np.random.rand(100,1) y=4+3*X+np.random.randn(100,1) X_b=np.c_[np.ones((100,1)),X]# add x0 = 1 to each instance theta_best=np.linalg.inv(X_b.T.dot(X_b)).dot(X_b.T).dot(y) numpy.rand(100,1) generates a 100*1 array, whose elements are random number ranging from 0 to 1. numpy.randn(100,1) generates a 100*1 array whose elements […]

We’ve learnt sklearn KFold. KFold splits an array into several groups. If the elements in the array are associated with a label/class, there would raise a problem. The ration of […]

sklearn kfold

KFold is a class in the model_selection module of sklearn package. The usage of KFold is simple: kfold=KFold(n_splits,shuffle, random_state) Now, a KFold object is ready. Notice that the data to […]