Added fake_epoch for observation

This commit is contained in:
lkrsnik 2017-07-07 12:45:47 +02:00
parent 592ad9b26b
commit 669aa6bbfd
2 changed files with 28 additions and 53 deletions

View File

@ -2,7 +2,9 @@
<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/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>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -32,8 +34,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="504">
<caret line="315" column="28" lean-forward="false" selection-start-line="315" selection-start-column="28" selection-end-line="315" selection-end-column="28" />
<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" />
<folding>
<element signature="e#24#63#0" expanded="true" />
</folding>
@ -135,6 +137,7 @@
<find>split_number</find>
<find>StringIO</find>
<find>shuffle_inputs</find>
<find>generator</find>
</findStrings>
</component>
<component name="Git.Settings">
@ -178,7 +181,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<PATH>
@ -205,49 +208,9 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="accetuation" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="accetuation" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="cnn" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="word_accetuation" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="accetuation" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="accetuation" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="cnn" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="word_accetuation" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="cnn_dictionary" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
@ -860,8 +823,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="504">
<caret line="315" column="28" lean-forward="false" selection-start-line="315" selection-start-column="28" selection-end-line="315" selection-end-column="28" />
<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" />
<folding>
<element signature="e#24#63#0" expanded="true" />
</folding>
@ -928,12 +891,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/character_based_ffnn_keras.ipynb">
<provider selected="true" editor-type-id="ipnb-editor">
<state>
<selected id="-1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cnn/word_accetuation/cnn_dictionary/character_based_ffnn_keras.ipynb" />
</component>
</project>

View File

@ -7,6 +7,7 @@ import h5py
import gc
import math
# functions for saving, loading and shuffling whole arrays to ram
def save_inputs(file_name, X, y, other_features=[]):
h5f = h5py.File(file_name, 'w')
@ -18,6 +19,7 @@ def save_inputs(file_name, X, y, other_features=[]):
h5f.create_dataset(k, data=v)
h5f.close()
def load_inputs(file_name, other_features=False):
h5f = h5py.File(file_name,'r')
X = h5f['X'][:]
@ -42,6 +44,7 @@ def shuffle_inputs(X, y, X_pure=[]):
else:
return X, y
# functions for saving and loading partial arrays to ram
def create_and_save_inputs(file_name, part, X, y, X_pure):
# X, y, X_pure = generate_full_vowel_matrix_inputs()
@ -51,6 +54,7 @@ def create_and_save_inputs(file_name, part, X, y, X_pure):
h5f.create_dataset(k,data=v)
h5f.close()
def load_extended_inputs(file_name, obtain_range):
h5f = h5py.File(file_name,'r')
X = h5f['X'][obtain_range[0]:obtain_range[1]]
@ -70,6 +74,7 @@ def create_and_save_shuffle_vector(file_name, shuffle_vector):
h5f.create_dataset(k,data=v)
h5f.close()
def load_shuffle_vector(file_name):
h5f = h5py.File(file_name,'r')
shuffle_vector = h5f['shuffle_vector'][[179859, 385513, 893430]]
@ -452,6 +457,19 @@ def generate_X_and_y_RAM_efficient(name, split_number):
h5f.close()
# 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]
while 1:
loc = 0
while loc < size:
if loc + batch_size >= size:
yield([orig_X[loc:size], orig_X_additional[loc:size]], orig_y[loc:size])
else:
yield([orig_X[loc:loc + batch_size], orig_X_additional[loc:loc + batch_size]], orig_y[loc:loc + batch_size])
loc += batch_size
# generator for inputs
def generate_arrays_from_file(path, batch_size):
h5f = h5py.File(path, 'r')