|
| 1 | +import sys |
| 2 | +import p1b1_baseline |
| 3 | +import p1b1 |
| 4 | + |
| 5 | +if (len(sys.argv) < 3): |
| 6 | + print('requires arg1=param and arg2=filename') |
| 7 | + sys.exit(1) |
| 8 | + |
| 9 | +parameterString = sys.argv[1] |
| 10 | +filename = sys.argv[2] |
| 11 | + |
| 12 | +print (parameterString) |
| 13 | +print ("filename is ", filename) |
| 14 | + |
| 15 | +epochs = int(parameterString[0].strip()) |
| 16 | +batch_size = int(parameterString[2].strip()) |
| 17 | +print ("Running p1b1 for epochs ", epochs, batch_size) |
| 18 | + |
| 19 | +# N1 = int(parameterString[2].strip()) |
| 20 | +# NE = int(parameterString[3].strip()) |
| 21 | + |
| 22 | +print("Set the correct paths for test and train file") |
| 23 | +test_path="/home/jain/Benchmarks/Data/Pilot1/P1B1.test.csv" |
| 24 | +train_path="/home/jain/Benchmarks/Data/Pilot1/P1B1.train.csv" |
| 25 | + |
| 26 | +print ("Starting to loading Xtrain and Xtest") |
| 27 | +X_train, X_test = p1b1.load_data(test_path=test_path, train_path=train_path) |
| 28 | +print ("Done loading Xtrain and Xtest") |
| 29 | + |
| 30 | +print ("Running p1b1 for epochs ", epochs) |
| 31 | +encoder, decoder, history = p1b1_baseline.run_p1b1(X_train, X_test, epochs=epochs, batch_size=batch_size) |
| 32 | +print ("Done running p1b1 for epochs ", epochs) |
| 33 | + |
| 34 | +# works around this error: |
| 35 | +# https://github.com/tensorflow/tensorflow/issues/3388 |
| 36 | +from keras import backend as K |
| 37 | +K.clear_session() |
| 38 | + |
| 39 | +# use the last validation_loss as the value to minimize |
| 40 | +val_loss = history.history['val_loss'] |
| 41 | +r = val_loss[-1] |
| 42 | + |
| 43 | +# writing the val loss to the output file |
| 44 | +with open(filename, 'w') as the_file: |
| 45 | + the_file.write(repr(r)) |
| 46 | + |
0 commit comments