Python में TensorFlow परिचय
Isaiah Hull
Visiting Associate Professor of Finance, BI Norwegian Business School
tensorflow ऑपरेशनTensorFlow में सामान्य लॉस फंक्शन्स के ऑपरेशन्स हैं
लॉस फंक्शन्स tf.keras.losses() से उपलब्ध हैं
tf.keras.losses.mse()tf.keras.losses.mae()tf.keras.losses.Huber()
# Import TensorFlow under standard alias
import tensorflow as tf
# Compute the MSE loss
loss = tf.keras.losses.mse(targets, predictions)
# Define a linear regression model
def linear_regression(intercept, slope = slope, features = features):
return intercept + features*slope
# Define a loss function to compute the MSE
def loss_function(intercept, slope, targets = targets, features = features):
# Compute the predictions for a linear model
predictions = linear_regression(intercept, slope)
# Return the loss
return tf.keras.losses.mse(targets, predictions)
# Compute the loss for test data inputs
loss_function(intercept, slope, test_targets, test_features)
10.77
# Compute the loss for default data inputs
loss_function(intercept, slope)
5.43
Python में TensorFlow परिचय