from tensorflow.keras.models import load_model from andi_funcs import import_tracks, package_tracks import os # Specify path to track data folder containing task2.txt path = '' """ Import data """ # Import x data tracks_1D, tracks_2D = import_tracks(path + '/task2.txt') """ 1D """ model = load_model('../Task2_Classification/Models/1D.h5') res_1D = model.predict(package_tracks(tracks_1D, dimensions=1, max_T=2001)) # max_T set to 2001 as competition data contains some tracks longer than 1000 """ 2D """ model = load_model('../Task2_Classification/Models/2D.h5') res_2D = model.predict(package_tracks(tracks_2D, dimensions=2, max_T=2001)) """ Save
import os import sys sys.path.append(os.path.dirname(os.path.realpath(__file__)) + '/../..') from andi_funcs import TrackGeneratorClassification, import_tracks, import_labels, package_tracks from models import classification_model_1d from tensorflow.keras.optimizers import Adam from tensorflow.keras.callbacks import ModelCheckpoint from tensorflow.keras.models import load_model import numpy as np # Load validation data tracks_val = package_tracks( import_tracks('../../Datasets/Validation/task2.txt')[0], dimensions=1, max_T=1001) classes_val = import_labels('../../Datasets/Validation/ref2.txt')[0] tracks_test = package_tracks(import_tracks('../../Datasets/Test/task2.txt')[0], dimensions=1, max_T=1001) # Run model model = classification_model_1d() model.compile(optimizer=Adam(learning_rate=0.001), loss='sparse_categorical_crossentropy', metrics=['accuracy']) model.summary() history = model.fit(TrackGeneratorClassification(batches=200, batch_size=32, dimensions=1,