Added custom actual accuracy metric which shows how many cases are correctly classified + changed to binary_crossentropy from mse

master
lkrsnik 7 years ago
parent 669aa6bbfd
commit 0cc949897f

@ -2,7 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="8a8ba9af-e1a4-433a-9968-475192610776" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/1_epoch.h5" afterPath="$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/1_epoch.h5" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/1_epoch_history.pkl" afterPath="$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/1_epoch_history.pkl" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/cnn.ipynb" afterPath="$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/cnn.ipynb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/prepare_data.py" afterPath="$PROJECT_DIR$/prepare_data.py" />
</list>
@ -34,8 +35,8 @@
<file leaf-file-name="prepare_data.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/prepare_data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="406">
<caret line="461" column="22" lean-forward="false" selection-start-line="461" selection-start-column="22" selection-end-line="461" selection-end-column="22" />
<state relative-caret-position="442">
<caret line="462" column="19" lean-forward="false" selection-start-line="462" selection-start-column="4" selection-end-line="462" selection-end-column="19" />
<folding>
<element signature="e#24#63#0" expanded="true" />
</folding>
@ -823,8 +824,8 @@
<entry file="file://$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/cnn_test_on_other_attributes.ipynb" />
<entry file="file://$PROJECT_DIR$/prepare_data.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="406">
<caret line="461" column="22" lean-forward="false" selection-start-line="461" selection-start-column="22" selection-end-line="461" selection-end-column="22" />
<state relative-caret-position="442">
<caret line="462" column="19" lean-forward="false" selection-start-line="462" selection-start-column="4" selection-end-line="462" selection-end-column="19" />
<folding>
<element signature="e#24#63#0" expanded="true" />
</folding>

@ -6,6 +6,7 @@ import numpy as np
import h5py
import gc
import math
import keras.backend as K
# functions for saving, loading and shuffling whole arrays to ram
@ -319,7 +320,8 @@ def generate_X_and_y(dictionary, max_word, max_num_vowels, content, vowels, acce
if len(word_accetuations) > 0:
y_value = 1/len(word_accetuations)
for el in word_accetuations:
y[i][el] = y_value
# y[i][el] = y_value
y[i][el] = 1
else:
y[i][0] = 1
# y[i][generate_presentable_y(word_accetuations, list(el[3]), max_num_vowels)] = 1
@ -457,6 +459,11 @@ def generate_X_and_y_RAM_efficient(name, split_number):
h5f.close()
# metric for calculation of correct results
def actual_accuracy(y_true, y_pred):
return K.mean(K.equal(K.mean(K.equal(K.round(y_true), K.round(y_pred)), axis=-1), 1.0))
# generator for inputs for tracking of data fitting
def generate_fake_epoch(orig_X, orig_X_additional, orig_y, batch_size):
size = orig_X.shape[0]

Loading…
Cancel
Save