# python

## Learn Hands-On Machine Learning with Scikit-Learn and TensorFlow-Chapter 11

To understand the content of this chapter, we need to review the concept about gradient and gradient descent. Gradient descent algorithm was introduced in chapter 4. In that chapter, a […]

## How to get the version of tensorflow and python installed on my system?

Knowing the version of Python and tensorflow currently installed on your PC is important as tensorflow may not run on the latest version of python, or you installed a 32-bit […]

## How is Python WITH statement implemented?

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 […]

## How to create a tensorflow.constant tensor with a list?

The tensorflow.constant is one of the functions to create a tensor with known values. Its usage is flexible and may not be what you think. The simplest usage would be: […]

## Learn Hands-On Machine Learning with Scikit-Learn and TensorFlow-Chapter 8

np.random.seed(4) m = 60 w1, w2 = 0.1, 0.3 noise = 0.1 angles = np.random.rand(m) * 3 * np.pi / 2 – 0.5 X = np.empty((m, 3)) X = np.empty((m, […]

## Learn Hands-On Machine Learning with Scikit-Learn and TensorFlow-Chapter 4

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 […]

## sklearn StratifiedKFold

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 […]