About importing tensorflow and keras during contests

Hello,

I’m running in a bit of trouble with my bot on the LoCM contest, but i believe it applies to other contests as well.

I’m trying to fit a neural network offline, write the trained weights in the code, and load them into keras/tensorflow on turn 1 (I’m using python2).

The problem is that the lines to import tensorflow and keras take a lot of time and my bot timeouts most of the time.

t_start = time.time()
import tensorflow as tf
from tensorflow import keras
print >> sys.stderr, “Time to import: %.2f” % ((time.time() - t_start)*1000.0)

Standard Error Stream:
Time to import: 2853.28

It varies between 2.5 and 2.8 seconds.

I know it’s not that hard to re-implement the predict method from keras, but given that NN are hot right now, I think it’s a bit sad to have every player who wants to try NNs re-implement it.

So yeah, if anyone has a solution to that issue, it would be very welcome :slight_smile:

Thank you!

PS: On a similar note, keras requires h5py to store and load models, I’ve re-implemented an alternative to do that using jsons since h5py is not on the servers. I guess it would be nice to have h5py available.

2 Likes

On a side note, could tensorflow be made available to Python3 too ?

3 Likes