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

Feature: redesigned functionality for mapping input and output tensors to and from training ranges #148

Merged
merged 2 commits into from
Apr 19, 2024
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
16 changes: 10 additions & 6 deletions src/inference_engine/inference_engine_m_.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module inference_engine_m_
contains
procedure :: infer
procedure :: to_json
procedure :: input_range
procedure :: output_range
procedure :: map_to_input_range
procedure :: map_from_output_range
procedure :: num_inputs
procedure :: num_outputs
procedure :: nodes_per_layer
Expand Down Expand Up @@ -82,16 +82,20 @@ impure elemental module function construct_from_json(file_) result(inference_eng

interface

pure module function input_range(self) result(my_input_range)
elemental module function map_to_input_range(self, tensor) result(normalized_tensor)
!! The result contains the input tensor values normalized to fall on the range used during training
implicit none
class(inference_engine_t), intent(in) :: self
type(tensor_range_t) my_input_range
type(tensor_t), intent(in) :: tensor
type(tensor_t) normalized_tensor
end function

pure module function output_range(self) result(my_output_range)
elemental module function map_from_output_range(self, normalized_tensor) result(tensor)
!! The result contains the output tensor values unnormalized via the inverse of the mapping used in training
implicit none
class(inference_engine_t), intent(in) :: self
type(tensor_range_t) my_output_range
type(tensor_t), intent(in) :: normalized_tensor
type(tensor_t) tensor
end function

pure module function to_exchange(self) result(exchange)
Expand Down
8 changes: 4 additions & 4 deletions src/inference_engine/inference_engine_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

contains

module procedure input_range
my_input_range = self%input_range_
module procedure map_to_input_range
normalized_tensor = self%input_range_%map_to_training_range(tensor)
end procedure

module procedure output_range
my_output_range = self%output_range_
module procedure map_from_output_range
tensor = self%output_range_%map_from_training_range(normalized_tensor)
end procedure

module procedure to_exchange
Expand Down
Loading