Python Import Keras Too Slow

Hi everyone. Just wondering if anyone has tried and successfully managed to import Keras module and load a model within the 3 seconds setup time limit. Simply importing Keras is taking too long and my algo receives damage when the first turn starts. Would appreciate some insights as to how to deployed Keras trained algos. Thanks.

How much damage do you usually take? Have you tried isolating the logic to just importing keras and loading your model on a very basic algo to make sure this is the root issue? I haven’t worked with keras before, but is the model you are loading unusually large or something of that nature?

I believe people have used keras before without this issue, so I am trying to diagnose if there is anything going on specific to your case

Yeah, I have seen other ML posts regarding Keras and Tensorflow and it didn’t seem like an issue for everyone else. I tried adding just ‘import keras’ or ‘from tensorflow.keras.models import load_model’ to the starter python algo without loading any model. When running this algo against itself locally, both players receive 5 damage on average. When running the algo against itself on Playground, the bottom player receives 5 damage on average and the top player receives no damage.

Playground might not be representative of our actual ranked/competition match servers, and I can’t make guarantees that things will perform the same on the playground as they do when your algo is competing online. Locally, things are dependent on your hardware.

If your algo is uploaded, it should automatically play some ranked matches that will appear when you click them on the myalgos page. Does this issue occur in ranked matches?

As a side note, top/bottom players should be handled identically. If things are very consistently favoring one side, I will investigate that. If you give me your algos name or ID I can pull it up and run some tests.

Ah, I see. Didn’t realize the playground performance would be very different from the competition pool. By looking at the competition replays it seems like import usually takes no more than 350ms.

In that case, I have more confidence tempering with wait time in the game-config file to adapt to my hardware performance. Thank you so much.

1 Like