def report_w2v_accuracy(X, y, nb_dim, prefix_string='w2v'): Y = get_w2v_labels(y, dim=nb_dim) Y_predict = model.predict(X, batch_size=batch_size, verbose=1) accuracy, class_, accuracy_c, class_c, accuracy_c2, class_c2 = accuracy_w2v_coarse(Y_predict, Y, dim=nb_dim) """ print(np.sum(class_,axis=0)) print(np.argmax(np.sum(class_,axis=0))) print(classes[np.argmax(np.sum(class_,axis=0))]) """ print("%s accuracy: %f" % (prefix_string, accuracy)) print("%s coarse accuracy: %f" % (prefix_string, accuracy_c)) print("%s coarse v2 accuracy: %f" % (prefix_string, accuracy_c2))
nb_dim = d break Y_train = get_w2v_labels(y_train, dim=nb_dim) Y_test = get_w2v_labels(y_test, dim=nb_dim) #NOTE: due to changes in keras, model has to be compiled before being used here #TODO: do the parameters that it is compiled with matter? might need to get them exactly optimizers = ['sgd','rmsprop','adam'] losses = ['mse','msle'] model.compile(optimizer=optimizers[2],loss=losses[0]) Y_predict_test = model.predict(X_test, batch_size=batch_size, verbose=1) Y_predict_train = model.predict(X_train, batch_size=batch_size, verbose=1) #test_accuracy, test_class = accuracy_w2v(Y_predict_test, Y_test, dim=nb_dim) test_accuracy, test_class, test_accuracy_c, test_class_c, test_accuracy_c2, test_class_c2 = accuracy_w2v_coarse(Y_predict_test, Y_test, dim=nb_dim) #train_accuracy, train_class = accuracy_w2v(Y_predict_train, Y_train, dim=nb_dim) train_accuracy, train_class, train_accuracy_c, train_class_c, train_accuracy_c2, train_class_c2 = accuracy_w2v_coarse(Y_predict_train, Y_train, dim=nb_dim) #sanity_accuracy, sanity_class = accuracy_w2v(Y_test, Y_test) print(np.sum(test_class,axis=0)) print(np.argmax(np.sum(test_class,axis=0))) print(classes[np.argmax(np.sum(test_class,axis=0))]) print(np.sum(train_class,axis=0)) print(np.argmax(np.sum(train_class,axis=0))) print(classes[np.argmax(np.sum(train_class,axis=0))]) #print(np.sum(sanity_class,axis=0)) print("w2v test accuracy: %f" % test_accuracy)