Skip to content

Commit

Permalink
Fix initilizations (#1)
Browse files Browse the repository at this point in the history
* fix: code structure in few cases.

* fix: code structure to align tf models.

* fix: layer naming, bn layer still remains.

* chore: change default epsilon and momentum in bn.
  • Loading branch information
sayakpaul authored Jun 6, 2022
1 parent 7ea1d01 commit 74cd9a0
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 121 deletions.
11 changes: 6 additions & 5 deletions src/transformers/modeling_tf_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class TFBaseModelOutputWithPoolingAndNoAttention(ModelOutput):
pooler_output (`tf.Tensor` of shape `(batch_size, hidden_size)`):
Last layer hidden-state after a pooling operation on the spatial dimensions.
hidden_states (`tuple(tf.Tensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
Tuple of `tf.Tensor` (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each layer) of shape `(batch_size, num_channels, height, width)`.
Tuple of `tf.Tensor` (one for the output of the embeddings, if the model has an embedding layer, + one for
the output of each layer) of shape `(batch_size, num_channels, height, width)`.
Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
"""
Expand Down Expand Up @@ -830,6 +830,7 @@ class TFSequenceClassifierOutputWithPast(ModelOutput):
hidden_states: Optional[Tuple[tf.Tensor]] = None
attentions: Optional[Tuple[tf.Tensor]] = None


@dataclass
class TFImageClassifierOutputWithNoAttention(ModelOutput):
"""
Expand All @@ -841,9 +842,9 @@ class TFImageClassifierOutputWithNoAttention(ModelOutput):
logits (`tf.Tensor` of shape `(batch_size, config.num_labels)`):
Classification (or regression if config.num_labels==1) scores (before SoftMax).
hidden_states (`tuple(tf.Tensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
Tuple of `tf.Tensor` (one for the output of the embeddings, if the model has an embedding layer, +
one for the output of each stage) of shape `(batch_size, num_channels, height, width)`. Hidden-states (also
called feature maps) of the model at the output of each stage.
Tuple of `tf.Tensor` (one for the output of the embeddings, if the model has an embedding layer, + one for
the output of each stage) of shape `(batch_size, num_channels, height, width)`. Hidden-states (also called
feature maps) of the model at the output of each stage.
"""

loss: Optional[tf.Tensor] = None
Expand Down
4 changes: 4 additions & 0 deletions src/transformers/models/regnet/configuration_regnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class RegNetConfig(PretrainedConfig):
documentation from [`PretrainedConfig`] for more information.
Args:
image_size (`int`, *optional*, defaults to 224):
Size of the input images.
num_channels (`int`, *optional*, defaults to 3):
The number of input channels.
embedding_size (`int`, *optional*, defaults to 64):
Expand Down Expand Up @@ -71,6 +73,7 @@ class RegNetConfig(PretrainedConfig):

def __init__(
self,
image_size=224,
num_channels=3,
embedding_size=32,
hidden_sizes=[128, 192, 512, 1088],
Expand All @@ -83,6 +86,7 @@ def __init__(
super().__init__(**kwargs)
if layer_type not in self.layer_types:
raise ValueError(f"layer_type={layer_type} is not one of {','.join(self.layer_types)}")
self.image_size = image_size
self.num_channels = num_channels
self.embedding_size = embedding_size
self.hidden_sizes = hidden_sizes
Expand Down
Loading

0 comments on commit 74cd9a0

Please sign in to comment.