|
This is my simple Neural Network using pure Numpy written in Python. What will be its Mojo equivalent? |
Answered by
erfanzar
Sep 25, 2023
Replies: 2 comments 4 replies
|
This seemed like an interesting challenge to see how far I can go with mojo, and so far I was able to get to first line of using from PythonInterface import Python
struct NeuralNetwork:
var input_size: Int
var hidden_size: Int
var output_size: Int
var W1: FloatLiteral
var W2: FloatLiteral
var b1: FloatLiteral
var b2: FloatLiteral
fn __init__(inout self, input_size: Int, hidden_size: Int, output_size: Int) raises:
self.input_size = input_size
self.hidden_size = hidden_size
self.output_size = output_size
# Initialize weights and biases
let np = Python.import_module("numpy")
self.W1 = np.random.randn(self.input_size, self.hidden_size)
# Rest lines are not yet changed beyond setting function typesI have few questions to mojo team:
|
2 replies
|
Check this code out https://github.com/erfanzar/EasyDeL/blob/mojo-beta/lib/mojo/EasyDel/matrix_/matrix_struct.%F0%9F%94%A5 |
2 replies
Answer selected by
lattner
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check this code out https://github.com/erfanzar/EasyDeL/blob/mojo-beta/lib/mojo/EasyDel/matrix_/matrix_struct.%F0%9F%94%A5