in train/train.py [0:0]
def train_model(data,labels):
## Train your own embeddings
model = CustomModel.define_network("none")
model.compile(loss = "binary_crossentropy", optimizer = "adam",
metrics = [tf.keras.metrics.AUC(multi_label=True),
tf.keras.metrics.MeanIoU(num_classes=6),
CustomModel.MultiLabelPrecision()])
## Split data
x_train, x_test, y_train, y_test = train_test_split(data, labels, test_size=0.20, shuffle = True, random_state = 123)
x_train, x_val, y_train, y_val = train_test_split(x_train, y_train, test_size=0.20, shuffle = True, random_state = 123)
print("Shape of train,test,val:",x_train.shape, y_train.shape, x_test.shape, y_test.shape, x_val.shape, y_val.shape)
## Fit tokenizer on x_train and tokenize both train and test
tokenizer = etl.get_tokenizer(x_train)
x_train = etl.tokenize(x_train,tokenizer)
x_test = etl.tokenize(x_test,tokenizer)
x_val = etl.tokenize(x_val,tokenizer)
save_tokenizer(tokenizer)
## Fit model and evaluate
model.fit(x_train, y_train, batch_size = 2048, epochs = 2,validation_data = (x_val,y_val),verbose=2)
print("Model Trained. Evaluate on test data")
results = model.evaluate(x_test, y_test, batch_size=2048,verbose=1)
print("test loss, test auc, test_IoU, test_precision:", results)
return model