thermography.classification.utils package

The utility functions associated to the thermography.classification module are implemented here.

Submodules

thermography.classification.utils.operations module

Module containing utility functions to combine multiple tensorflow operations into a single function call.

weight_variable(name: str, shape: list) → tensorflow.python.framework.ops.Tensor[source]

Generates or returns an existing tensorflow variable to be used as weight.

Parameters:
  • name – Name of the variable to be returned.
  • shape – Shape of the variable to be returned.

:return A tf.Variable with the name and shape passed as argument, initialized with a truncated normal initializer.

bias_variable(name: str, shape: list) → tensorflow.python.framework.ops.Tensor[source]

Generates or returns an existing tensorflow variable to be used as a bias.

Parameters:
  • name – Name of the variable to be returned.
  • shape – Shape of the variable to be returned.
Returns:

A tf.variable with the name and shape passed as argument, initialized with a constant initializer.

conv2d(name: str, x: tensorflow.python.framework.ops.Tensor, W: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]

Returns the graph node associated to the convolution between the input parameters.

Parameters:
  • name – Name to give to the resulting convolution.
  • x – Tensor to be convolved.
  • W – Weight variable to be used in the convolution.
Returns:

A new tensor consisting of the convolution between the two input parameters.

conv_relu(x: tensorflow.python.framework.ops.Tensor, kernel_shape: list, bias_shape: list, name: str = '') → tensorflow.python.framework.ops.Tensor[source]

Performs and returns a convolution, followed by bias addition and non-linearity (relu).

Parameters:
  • x – Input tensor to the convolution-bias-relu operation.
  • kernel_shape – Kernel shape to be used in the convolution.
  • bias_shape – Bias shape to be added to the result of the convolution.
  • name – Name of the returned operation.
Returns:

A new tensor consisting of the convolution-bias-relu operation.

max_pool_2x2(name: str, x: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]

Performs a max_pool of size 2x2 to the input parameter.

Parameters:
  • name – Name to assign to the returned operation.
  • x – input tensor.
max_pool_4x4(name: str, x: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]

Performs a max_pool of size 4x4 to the input parameter.

Parameters:
  • name – Name to assign to the returned operation.
  • x – input tensor.
max_pool_kxk(name: str, x: tensorflow.python.framework.ops.Tensor, k: int) → tensorflow.python.framework.ops.Tensor[source]

Performs a max_pool of size kxk to the input parameter.

Parameters:
  • name – Name to assign to the returned operation.
  • x – input tensor.
  • k – size of the pooling operation.

thermography.classification.utils.kernel_summaries module

kernel_to_histogram_summary(kernel: tensorflow.python.framework.ops.Tensor, summary_name: str, collection: str = 'histograms') → None[source]

Generates a summary histogram from the kernel passed as argument and adds it to the collection specified.

Parameters:
  • kernel – Tensor representing a kernel.
  • summary_name – Name to give to the generated summary.
  • collection – Summary collection where the histogram summary is added.
kernel_to_image_summary(kernel: tensorflow.python.framework.ops.Tensor, summary_name: str, max_images=3, collection: str = 'kernels') → None[source]

Converts a kernel tensor of shape [width, height, in_channels, out_channels] to an image summary.

Parameters:
  • kernel – Tensor representing the convolutional kernel.
  • summary_name – Name to give to the summary.
  • max_images – Maximal number of images to extract from the kernel tensor (slices).
  • collection – Summary collection where the image summary is added.