361d87cc6d4fe86c82204becce00f4d595e1c459,open_seq2seq/utils/helpers.py,,_restore_embed,#Any#Any#Any#,415

Before Change



def _restore_embed(embed_var, var_to_shape_map, reader):
  has_embed = len([var for var in var_to_shape_map if "EmbeddingMatrix" in var]) > 0
  if has_embed:
    return None, False // assume same name
  for var in var_to_shape_map:
    if var.endswith("dense/kernel") and var_to_shape_map[var] == tf.transpose(embed_var).shape:
      print("Assigning", var, "to", embed_var.name)
      return embed_var.assign(reader.get_tensor(var).T), True

After Change


      print("Assigning", var, "to", embed_var.name)
      tensor = reader.get_tensor(var).T
      if tensor.dtype != var.dtype.as_numpy_dtype():
        return embed_var.assign(tf.cast(tensor, embed_var.dtype)), True
      return embed_var, False
  return None, None
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 361d87cc6d4fe86c82204becce00f4d595e1c459
Time: 2019-01-09
Author: jasoli@nvidia.com
File Name: open_seq2seq/utils/helpers.py
Class Name:
Method Name: _restore_embed


Project Name: tryolabs/luminoth
Commit Name: dfe26d7233aaccb1d344ff9ba9995d722503b7e7
Time: 2018-03-20
Author: joaquin.alori@gmail.com
File Name: luminoth/models/ssd/ssd.py
Class Name: SSD
Method Name: _build


Project Name: NVIDIA/OpenSeq2Seq
Commit Name: 44ae6129731ee1d225db8a5f1bafea5fd4b9b542
Time: 2019-02-06
Author: boris.ginsburg@gmail.com
File Name: open_seq2seq/parts/transformer/common.py
Class Name: LayerNormalization
Method Name: call