Refactor: Removed un-necessary object base class (#32230)

* Refactored to remove un-necessary object base class.

* small fix.
This commit is contained in:
Sai-Suraj-27
2024-07-26 14:03:02 +05:30
committed by GitHub
parent 1c7ebf1d6e
commit b8e5cd5396
56 changed files with 89 additions and 89 deletions

View File

@@ -557,7 +557,7 @@ class MultiHeadedAttention(nn.Module):
return context
class DecoderState(object):
class DecoderState:
"""Interface for grouping together the current state of a recurrent
decoder. In the simplest case just represents the hidden state of
the model. But can also be used for implementing various forms of
@@ -694,7 +694,7 @@ def build_predictor(args, tokenizer, symbols, model, logger=None):
return translator
class GNMTGlobalScorer(object):
class GNMTGlobalScorer:
"""
NMT re-ranking score from
"Google's Neural Machine Translation System" :cite:`wu2016google`
@@ -717,7 +717,7 @@ class GNMTGlobalScorer(object):
return normalized_probs
class PenaltyBuilder(object):
class PenaltyBuilder:
"""
Returns the Length and Coverage Penalty function for Beam Search.
@@ -763,7 +763,7 @@ class PenaltyBuilder(object):
return logprobs
class Translator(object):
class Translator:
"""
Uses a model to translate a batch of sentences.
@@ -1002,7 +1002,7 @@ def tile(x, count, dim=0):
#
class BertSumOptimizer(object):
class BertSumOptimizer:
"""Specific optimizer for BertSum.
As described in [1], the authors fine-tune BertSum for abstractive

View File

@@ -3,7 +3,7 @@ import torch
from transformers import AutoTokenizer
class FSNERTokenizerUtils(object):
class FSNERTokenizerUtils:
def __init__(self, pretrained_model_name_or_path):
self.tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path)

View File

@@ -417,7 +417,7 @@ class ShapeSpec(namedtuple("_ShapeSpec", ["channels", "height", "width", "stride
return super().__new__(cls, channels, height, width, stride)
class Box2BoxTransform(object):
class Box2BoxTransform:
"""
This R-CNN transformation scales the box's width and height
by exp(dw), exp(dh) and shifts a box's center by the offset
@@ -519,7 +519,7 @@ class Box2BoxTransform(object):
return pred_boxes
class Matcher(object):
class Matcher:
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicted element will have exactly zero or one matches; each
@@ -622,7 +622,7 @@ class Matcher(object):
match_labels[pred_inds_with_highest_quality] = 1
class RPNOutputs(object):
class RPNOutputs:
def __init__(
self,
box2box_transform,
@@ -1132,7 +1132,7 @@ class ROIPooler(nn.Module):
return output
class ROIOutputs(object):
class ROIOutputs:
def __init__(self, cfg, training=False):
self.smooth_l1_beta = cfg.ROI_BOX_HEAD.SMOOTH_L1_BETA
self.box2box_transform = Box2BoxTransform(weights=cfg.ROI_BOX_HEAD.BBOX_REG_WEIGHTS)

View File

@@ -108,7 +108,7 @@ class TopKBinarizer(autograd.Function):
return gradOutput, None
class MagnitudeBinarizer(object):
class MagnitudeBinarizer:
"""
Magnitude Binarizer.
Computes a binary mask M from a real value matrix S such that `M_{i,j} = 1` if and only if `S_{i,j}`

View File

@@ -284,7 +284,7 @@ def make_fast_generalized_attention(
return attention_fn
class RandomMatrix(object):
class RandomMatrix:
r"""
Abstract class providing a method for constructing 2D random arrays. Class is responsible for constructing 2D
random arrays.
@@ -348,7 +348,7 @@ class GaussianOrthogonalRandomMatrix(RandomMatrix):
return jnp.matmul(jnp.diag(multiplier), final_matrix)
class FastAttention(object):
class FastAttention:
r"""
Abstract class providing a method for fast attention. Class is responsible for providing a method
<dot_product_attention> for fast approximate attention.

View File

@@ -417,7 +417,7 @@ class ShapeSpec(namedtuple("_ShapeSpec", ["channels", "height", "width", "stride
return super().__new__(cls, channels, height, width, stride)
class Box2BoxTransform(object):
class Box2BoxTransform:
"""
This R-CNN transformation scales the box's width and height
by exp(dw), exp(dh) and shifts a box's center by the offset
@@ -519,7 +519,7 @@ class Box2BoxTransform(object):
return pred_boxes
class Matcher(object):
class Matcher:
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicted element will have exactly zero or one matches; each
@@ -622,7 +622,7 @@ class Matcher(object):
match_labels[pred_inds_with_highest_quality] = 1
class RPNOutputs(object):
class RPNOutputs:
def __init__(
self,
box2box_transform,
@@ -1132,7 +1132,7 @@ class ROIPooler(nn.Module):
return output
class ROIOutputs(object):
class ROIOutputs:
def __init__(self, cfg, training=False):
self.smooth_l1_beta = cfg.ROI_BOX_HEAD.SMOOTH_L1_BETA
self.box2box_transform = Box2BoxTransform(weights=cfg.ROI_BOX_HEAD.BBOX_REG_WEIGHTS)