New Dataset Generator, How to differentiate the loss function?
This commit is contained in:
@ -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]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user