New Dataset Generator, How to differentiate the loss function?

This commit is contained in:
Steffen Illium
2020-02-18 21:58:31 +01:00
parent 61c5cb44a0
commit 8424251ca0
13 changed files with 250 additions and 39 deletions

View File

@ -1,4 +1,7 @@
import shelve
from pathlib import Path
from collections import UserDict
import copy
from math import sqrt
@ -130,3 +133,30 @@ class Map(object):
# https: // matplotlib.org / api / pyplot_summary.html?highlight = colormaps
img = ax.imshow(self.as_array, cmap='Greys_r')
return dict(img=img, fig=fig, ax=ax)
class MapStorage(object):
def __init__(self, map_root, load_all=False):
self.data = dict()
self.map_root = Path(map_root)
if load_all:
for map_file in self.map_root.glob('*.bmp'):
_ = self[map_file.name]
def __getitem__(self, item):
if item in hasattr(self, item):
return self.__getattribute__(item)
else:
with shelve.open(self.map_root / f'{item}.pik', flag='r') as d:
self.__setattr__(item, d['map']['map'])
return self[item]