December 2018
Intermediate to advanced
764 pages
18h 18m
English
The following is the complete code for ridge regularized regression to train the model in order to predict Boston house pricing:
num_outputs = y_train.shape[1]num_inputs = X_train.shape[1]x_tensor = tf.placeholder(dtype=tf.float32, shape=[None, num_inputs], name='x')y_tensor = tf.placeholder(dtype=tf.float32, shape=[None, num_outputs], name='y')w = tf.Variable(tf.zeros([num_inputs, num_outputs]), dtype=tf.float32, name='w')b = tf.Variable(tf.zeros([num_outputs]), dtype=tf.float32, name='b')model = tf.matmul(x_tensor, w) + bridge_param = tf.Variable(0.8, dtype=tf.float32)ridge_loss = tf.reduce_mean(tf.square(w)) * ridge_paramloss = tf.reduce_mean(tf.square(model - y_tensor)) + ridge_losslearning_rate = 0.001optimizer = ...
Read now
Unlock full access