MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _log_weight_as_image

Method _log_weight_as_image

tensorflow/python/keras/callbacks.py:1766–1788  ·  view source on GitHub ↗

Logs a weight as a TensorBoard image.

(self, weight, weight_name, epoch)

Source from the content-addressed store, hash-verified

1764 writer.flush()
1765
1766 def _log_weight_as_image(self, weight, weight_name, epoch):
1767 """Logs a weight as a TensorBoard image."""
1768 w_img = array_ops.squeeze(weight)
1769 shape = K.int_shape(w_img)
1770 if len(shape) == 1: # Bias case
1771 w_img = array_ops.reshape(w_img, [1, shape[0], 1, 1])
1772 elif len(shape) == 2: # Dense layer kernel case
1773 if shape[0] > shape[1]:
1774 w_img = array_ops.transpose(w_img)
1775 shape = K.int_shape(w_img)
1776 w_img = array_ops.reshape(w_img, [1, shape[0], shape[1], 1])
1777 elif len(shape) == 3: # ConvNet case
1778 if K.image_data_format() == 'channels_last':
1779 # Switch to channels_first to display every kernel as a separate
1780 # image.
1781 w_img = array_ops.transpose(w_img, perm=[2, 0, 1])
1782 shape = K.int_shape(w_img)
1783 w_img = array_ops.reshape(w_img, [shape[0], shape[1], shape[2], 1])
1784
1785 shape = K.int_shape(w_img)
1786 # Not possible to handle 3D convnets etc.
1787 if len(shape) == 4 and shape[-1] in [1, 3, 4]:
1788 summary_ops_v2.image(weight_name, w_img, step=epoch)
1789
1790 def _log_embeddings(self, epoch):
1791 embeddings_ckpt = os.path.join(self.log_dir, 'train',

Callers 1

_log_weightsMethod · 0.95

Calls 2

reshapeMethod · 0.80
transposeMethod · 0.80

Tested by

no test coverage detected