Skip to content

Instantly share code, notes, and snippets.

@AlessandroMondin
Last active May 10, 2022 17:04
Show Gist options
  • Save AlessandroMondin/5b2b9efe1b6cd6c63c62d752af8b7523 to your computer and use it in GitHub Desktop.
Save AlessandroMondin/5b2b9efe1b6cd6c63c62d752af8b7523 to your computer and use it in GitHub Desktop.
def logistic_regression(self, X, W, b):
if self.library == "tf":
# flatten_X has shape (batch_size, W*H*Channels) --> in our case (64, 32*32*3)
flatten_X = tf.reshape(X, (-1, W.shape[0]))
out = self.softmax(tf.matmul(flatten_X, W) + b)
else:
flatten_X = X.reshape((-1, W.shape[0]))
out = self.softmax(torch.matmul(flatten_X,W) + b)
return out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment