December 2018
Intermediate to advanced
764 pages
18h 18m
English
We define the lasso parameter to have the value 0.8:
lasso_param = tf.Variable(0.8, dtype=tf.float32)lasso_loss = tf.reduce_mean(tf.abs(w)) * lasso_param
Setting the lasso parameter as zero means no regularization as the term becomes zero. Higher the value of the regularization term, higher the penalty. The following is the complete code for lasso 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], ...
Read now
Unlock full access