Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit tests for tensorflow 2.3. #16

Merged
merged 1 commit into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions delta/ml/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def _process_block(self, pred_image, x, y, labels):
"""

def _predict_array(self, data):
net_input_shape = self._model.get_input_shape_at(0)[1:]
net_output_shape = self._model.get_output_shape_at(0)[1:]
net_input_shape = self._model.input_shape[1:]
net_output_shape = self._model.output_shape[1:]

assert net_input_shape[2] == data.shape[2],\
'Model expects %d input channels, data has %d channels' % (net_input_shape[2], data.shape[2])
Expand Down Expand Up @@ -101,8 +101,8 @@ def predict(self, image, label=None, input_bounds=None):
Results are limited to `input_bounds`. Returns output, the meaning of which
depends on the subclass.
"""
net_input_shape = self._model.get_input_shape_at(0)[1:]
net_output_shape = self._model.get_output_shape_at(0)[1:]
net_input_shape = self._model.input_shape[1:]
net_output_shape = self._model.output_shape[1:]
offset_r = -net_input_shape[0] + net_output_shape[0]
offset_c = -net_input_shape[1] + net_output_shape[1]
block_size_x = net_input_shape[0] * (_TILE_SIZE // net_input_shape[0])
Expand Down Expand Up @@ -166,7 +166,7 @@ def __init__(self, model, output_image=None, show_progress=False,
self._errors = None

def _initialize(self, shape, label, image):
net_output_shape = self._model.get_output_shape_at(0)[1:]
net_output_shape = self._model.output_shape[1:]
self._num_classes = net_output_shape[-1]
if label:
self._errors = np.zeros(shape, dtype=np.bool)
Expand Down Expand Up @@ -244,7 +244,7 @@ def __init__(self, model, output_image=None, show_progress=False, transform=None
self._transform = transform

def _initialize(self, shape, label, image):
net_output_shape = self._model.get_output_shape_at(0)[1:]
net_output_shape = self._model.output_shape[1:]
if self._output_image is not None:
dtype = np.float32 if self._transform is None else self._transform[1]
bands = net_output_shape[-1] if self._transform is None else self._transform[2]
Expand Down
4 changes: 2 additions & 2 deletions delta/ml/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def train(model_fn, dataset : ImageryDataset, training_spec):
model.compile(optimizer=training_spec.optimizer, loss=loss,
metrics=training_spec.metrics)

input_shape = model.get_input_at(0).shape
output_shape = model.get_output_at(0).shape
input_shape = model.input_shape
output_shape = model.output_shape
chunk_size = input_shape[1]

assert len(input_shape) == 4, 'Input to network is wrong shape.'
Expand Down