ierhon's picture
Upload eval.py
fbeb372
raw
history blame
685 Bytes
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing.sequence import pad_sequences
import numpy as np
import csv
from tqdm import tqdm
model = load_model("net.h5")
dataset = "dataset_test.csv"
inp_len = 32
X = []
y = []
with open(dataset, 'r') as f:
csv_reader = csv.reader(f)
for row in tqdm(csv_reader):
if row == []: continue
label = int(row[0])
text = row[1]
text = [ord(char) for char in text]
X.append(text)
y.append(label)
X = np.array(pad_sequences(X, maxlen=inp_len, padding='post'))
y = np.array(y)
loss, accuracy = model.evaluate(X, y)
print(f"Loss: {loss}\nAccuracy: {accuracy}")