Check this code out https://github.com/erfanzar/EasyDeL/blob/mojo-beta/lib/mojo/EasyDel/matrix_/matrix_struct.%F0%9F%94%A5
","upvoteCount":1,"url":"https://github.com/modular/modular/discussions/136#discussioncomment-7104962"}}}-
|
This is my simple Neural Network using pure Numpy written in Python. What will be its Mojo equivalent? |
Beta Was this translation helpful? Give feedback.
-
|
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:
|
Beta Was this translation helpful? Give feedback.
-
|
Check this code out https://github.com/erfanzar/EasyDeL/blob/mojo-beta/lib/mojo/EasyDel/matrix_/matrix_struct.%F0%9F%94%A5 |
Beta Was this translation helpful? Give feedback.
Check this code out https://github.com/erfanzar/EasyDeL/blob/mojo-beta/lib/mojo/EasyDel/matrix_/matrix_struct.%F0%9F%94%A5