From b53e1bf2b7fae3de9a6a7bb49d374b8706ada6ae Mon Sep 17 00:00:00 2001 From: Miguel Mendes Date: Sun, 28 Jan 2018 08:43:16 -0200 Subject: [PATCH 1/2] Fix typos on CRF docstrings --- keras_contrib/layers/crf.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/keras_contrib/layers/crf.py b/keras_contrib/layers/crf.py index 9cc06eb16..0d6a0e680 100644 --- a/keras_contrib/layers/crf.py +++ b/keras_contrib/layers/crf.py @@ -26,7 +26,7 @@ class CRF(Layer): This implementation has two modes for optimization: 1. (`join mode`) optimized by maximizing join likelihood, which is optimal in theory of statistics. - Note that in this case, CRF mast be the output/last layer. + Note that in this case, CRF must be the output/last layer. 2. (`marginal mode`) return marginal probabilities on each time step and optimized via composition likelihood (product of marginal likelihood), i.e., using `categorical_crossentropy` loss. Note that in this case, CRF can be either the last layer or an intermediate layer (though not explored). @@ -72,9 +72,9 @@ class CRF(Layer): gives one-hot representation of the best path at test (prediction) time, while the latter is recommended and chosen as default when `learn_mode = 'marginal'`, which produces marginal probabilities for each time step. - sparse_target: Boolen (default False) indicating if provided labels are one-hot or + sparse_target: Boolean (default False) indicating if provided labels are one-hot or indices (with shape 1 at dim 3). - use_boundary: Boolen (default True) inidicating if trainable start-end chain energies + use_boundary: Boolean (default True) inidicating if trainable start-end chain energies should be added to model. use_bias: Boolean, whether the layer uses a bias vector. kernel_initializer: Initializer for the `kernel` weights matrix, @@ -372,7 +372,7 @@ def add_boundary_energy(self, energy, mask, start, end): return energy def get_log_normalization_constant(self, input_energy, mask, **kwargs): - """Compute logarithm of the normalization constance Z, where + """Compute logarithm of the normalization constant Z, where Z = sum exp(-E) -> logZ = log sum exp(-E) =: -nlogZ """ # should have logZ[:, i] == logZ[:, j] for any i, j @@ -436,7 +436,7 @@ def step(self, input_energy_t, states, return_logZ=True): def recursion(self, input_energy, mask=None, go_backwards=False, return_sequences=True, return_logZ=True, input_length=None): """Forward (alpha) or backward (beta) recursion - If `return_logZ = True`, compute the logZ, the normalization constance: + If `return_logZ = True`, compute the logZ, the normalization constant: \[ Z = \sum_{y1, y2, y3} exp(-E) # energy = \sum_{y1, y2, y3} exp(-(u1' y1 + y1' W y2 + u2' y2 + y2' W y3 + u3' y3)) From 45ac94619347e8370e13cc41aa6e2d40d6cfd850 Mon Sep 17 00:00:00 2001 From: Miguel Mendes Date: Sun, 28 Jan 2018 08:56:41 -0200 Subject: [PATCH 2/2] Fix more typos --- keras_contrib/datasets/coco.py | 2 +- keras_contrib/datasets/conll2000.py | 2 +- keras_contrib/initializers/convaware.py | 2 +- keras_contrib/layers/crf.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/keras_contrib/datasets/coco.py b/keras_contrib/datasets/coco.py index a5c4d23f2..0309292b0 100644 --- a/keras_contrib/datasets/coco.py +++ b/keras_contrib/datasets/coco.py @@ -340,7 +340,7 @@ def coco_image_segmentation_stats(seg_mask_output_paths, annotation_paths, seg_m # print('\ntarget_shape:', target_shape) mask_one_hot = np.zeros(target_shape, dtype=np.uint8) - # Note to only count backgroung pixels once, we define a temporary + # Note to only count background pixels once, we define a temporary # null class of 0, and shift all class category ids up by 1 mask_one_hot[:, :, 0] = 1 # every pixel begins as background diff --git a/keras_contrib/datasets/conll2000.py b/keras_contrib/datasets/conll2000.py index 5561f1761..d0bc89204 100755 --- a/keras_contrib/datasets/conll2000.py +++ b/keras_contrib/datasets/conll2000.py @@ -43,7 +43,7 @@ def _process_data(data, vocab, pos_tags, chunk_tags, maxlen=None, onehot=False): x = pad_sequences(x, maxlen) # left padding - y_pos = pad_sequences(y_pos, maxlen, value=-1) # lef padded with -1. Indeed, any interger works as it will be masked + y_pos = pad_sequences(y_pos, maxlen, value=-1) # lef padded with -1. Indeed, any integer works as it will be masked y_chunk = pad_sequences(y_chunk, maxlen, value=-1) if onehot: diff --git a/keras_contrib/initializers/convaware.py b/keras_contrib/initializers/convaware.py index 72ae73a9d..3c7873a9d 100644 --- a/keras_contrib/initializers/convaware.py +++ b/keras_contrib/initializers/convaware.py @@ -9,7 +9,7 @@ class ConvolutionAware(Initializer): """ Initializer that generates orthogonal convolution filters in the fourier space. If this initializer is passed a shape that is not 3D or 4D, - orthogonal intialization will be used. + orthogonal initialization will be used. # Arguments eps_std: Standard deviation for the random normal noise used to break symmetry in the inverse fourier transform. diff --git a/keras_contrib/layers/crf.py b/keras_contrib/layers/crf.py index 0d6a0e680..fa2408ec9 100644 --- a/keras_contrib/layers/crf.py +++ b/keras_contrib/layers/crf.py @@ -74,7 +74,7 @@ class CRF(Layer): which produces marginal probabilities for each time step. sparse_target: Boolean (default False) indicating if provided labels are one-hot or indices (with shape 1 at dim 3). - use_boundary: Boolean (default True) inidicating if trainable start-end chain energies + use_boundary: Boolean (default True) indicating if trainable start-end chain energies should be added to model. use_bias: Boolean, whether the layer uses a bias vector. kernel_initializer: Initializer for the `kernel` weights matrix,