Skip to content
Snippets Groups Projects
Commit b54b1fee authored by Laura Christine Kühle's avatar Laura Christine Kühle
Browse files

Improved verbose output.

parent 6c71e398
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
TODO: Improve '_generate_cell_data'
TODO: Extract normalization (Combine smooth and troubled before normalizing) -> Done
TODO: Adapt code to generate both normalized and non-normalized data -> Done
TODO: Improve verbose output
TODO: Improve verbose output -> Done
TODO: Change order of methods -> Done
"""
......@@ -15,6 +15,7 @@ import os
import Initial_Condition
import DG_Approximation
import timeit
class TrainingDataGenerator(object):
......@@ -46,11 +47,14 @@ class TrainingDataGenerator(object):
os.makedirs(self._data_dir)
def build_training_data(self, num_samples):
print('Calculating training data...')
tic = timeit.default_timer()
print('Calculating training data...\n')
data_dict = self._calculate_data_set(num_samples)
print('Finished calculating training data!')
self._save_data(data_dict)
toc = timeit.default_timer()
print('Total runtime:', toc-tic)
return data_dict
def _calculate_data_set(self, num_samples):
......@@ -78,6 +82,11 @@ class TrainingDataGenerator(object):
'normalized_input': norm_input_matrix}
def _generate_cell_data(self, num_samples, initial_conditions, is_smooth):
troubled_indicator = 'without' if is_smooth else 'with'
print('Calculating data ' + troubled_indicator + ' troubled cells...')
print('Samples to complete:', num_samples)
tic = timeit.default_timer()
num_function_samples = num_samples//len(initial_conditions)
function_id = 0
input_data = np.zeros((num_samples, 5))
......@@ -121,6 +130,10 @@ class TrainingDataGenerator(object):
if count % 100 == 0:
print(str(count) + ' samples completed.')
toc = timeit.default_timer()
print('Finished calculating data ' + troubled_indicator + ' troubled cells!')
print('Calculation time:', toc-tic, '\n')
# Shuffle input data
order = np.random.permutation(num_samples)
input_data = input_data[order]
......@@ -162,6 +175,7 @@ class TrainingDataGenerator(object):
return normalized_input_data
def _save_data(self, data):
print('Saving training data.')
for key in data.keys():
name = self._data_dir + '/' + key + '_data.npy'
np.save(name, data[key])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment