Keras to Pytorch model

Hi dear community,

I’ve started with PyTorch recently, and I’m a bit confused about the basic problems. So, my issue is - what will be the Pytorch analogue for this the most simple Keras model:

model = tf.keras.models.Sequential([
      tf.keras.layers.Dense(
          10, activation=tf.nn.softmax, kernel_initializer='zeros', input_shape=(784,))])

I’ll appreciate any help and advise

I think this might help you Pytorch equivalent of Keras

So, if you want a 1:1 translation you’d probably end up with

model = torch.nn.Sequential(
    torch.nn.Linear(
        784, # number inputs
        10 # number outputs
    ),
    torch.nn.Softmax(dim=-1)
 )

And then call a function, initializing the weights with model.apply(init_func), where init_func is a function which will be called on every submodule of model.