Страницы: 1
I'm having difficulty understanding some of the deep-learning interview questions I've come across from an online resource. Specifically, I'm having trouble with some of the code examples. I'm hoping someone can provide some insight into how to approach these questions.
I've included some of the code examples below for reference. Any help would be greatly appreciated.
Example 1:
def deepLearningModel(data): # Initialize weights weights = np.random.rand(len(data[0])) # Initialize bias bias = 0 # Hyperparameters learningRate = 0.1 numEpochs = 2000 # Train the model for epoch in range(numEpochs): # Calculate predicted values preds = np.dot(data, weights) + bias # Calculate gradients gradients = 2 * np.dot(data.T, (preds - data[:,-1])) weights -= learningRate * gradients bias -= learningRate * np.sum(preds - data[:,-1]) return weights, bias
Example 2:
def deepLearningModel(X, Y): # Initialize weights weights = np.random.rand(X.shape[1]) # Initialize bias bias = 0 # Hyperparameters learningRate = 0.1 numEpochs = 2000 # Train the model for epoch in range(numEpochs): # Calculate predicted values preds = np.dot(X, weights) + bias # Calculate gradients gradients = 2 * np.dot(X.T, (preds - Y)) weights -= learningRate * gradients bias -= learningRate * np.sum(preds - Y) return weights, bias
Отредактировано Magnet12 (18-04-2023 12:20:41)
Отсутствует
Страницы: 1