Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traing #3

Open
smie14353015 opened this issue Jun 8, 2019 · 3 comments
Open

Traing #3

smie14353015 opened this issue Jun 8, 2019 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@smie14353015
Copy link

Dear off99555:

If I want to use this code for classification, can you show me how to train your permutation model?

Thanks

@offchan42
Copy link
Owner

offchan42 commented Jun 8, 2019

I recommend you to run python permutational_layer.py and look at the bottom section to learn how it's working. But if you don't want to learn about it too deep, please see the example of how to use PermutationalModule():
https://github.com/off99555/superkeras/blob/daef899315685c7d0c5f8f4ec8f56a01899c9315/permutational_layer.py#L239-L265

Think of it as a function that returns a Keras model. And a Keras model can be used interchangeably with Keras layer. It means you can think of it as something similar to Dense() function.
So if you want to do classification, you will have to do something like

a=Input(...)
b=Input(...)
c=Input(...)
module = PermutationalModule(...) # create the keras model
out = module([a,b,c]) # use the keras model with 3 inputs (specify number of inputs in arguments of PermutationalModule()
out = Dense(NUMBER_OF_CLASSES, activation='softmax')(out)
model = keras.models.Model(inputs=[a,b,c], outputs=out)
model.compile('adam', loss='categorical_crossentropy', metrics=['accuracy'])

which is about using functional API of keras (because there are multiple inputs).

I'm not sure if the code prototype I gave you will work out of the box. But try fix it. The idea will be something like that.

@smie14353015
Copy link
Author

Thanks for your reply. I think I got the points.

And I found the output of the PermutationalModule is like (batch size, feature dimension = 52),
if I want to connect this to LSTM layers, I think I need to Reshape this output like LSTM_input = Reshape((5,52))(perm_model.output) to shape(batch size, timestamps=5, feature = 52), something wrong happened: ValueError: total size of new array must be unchanged, will this possible to connect this model to LSTM layer?

By the way, can I consider this PermutationalModule as an encoder which means I don't need to train?(Stupid I know)

Thanks,

@offchan42
Copy link
Owner

I have never tried PermutationalModule with LSTM before so I'm not sure how to go about it. I think it's doable but you will have to experiment with it.
In the paper that I followed, it's simply a feed-forward network, not LSTM.
PermutationalModule has weights so you need to train it.

@offchan42 offchan42 added the question Further information is requested label Sep 11, 2019
@offchan42 offchan42 self-assigned this Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants