We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[INSERT DESCRIPTION OF THE PROBLEM]
[INSERT CODE HERE]
# ======================================================== # ###### tensorlayerx.ops.Pad源码###### # ======================================================== # class Pad(object): def __init__(self, paddings, mode="REFLECT", constant_values=0): if mode not in ['CONSTANT', 'REFLECT', 'SYMMETRIC']: raise Exception("Unsupported mode: {}".format(mode)) if mode == 'SYMMETRIC': raise NotImplementedError self.paddings = paddings self.mode = mode.lower() self.constant_values = constant_values def __call__(self, x): if len(x.shape) == 3: data_format = 'NLC' self.paddings = self.correct_paddings(len(x.shape), self.paddings, data_format) elif len(x.shape) == 4: data_format = 'NHWC' self.paddings = self.correct_paddings(len(x.shape), self.paddings, data_format) elif len(x.shape) == 5: data_format = 'NDHWC' self.paddings = self.correct_paddings(len(x.shape), self.paddings, data_format) else: raise NotImplementedError('Please check the input shape.') return pd.nn.functional.pad(x, self.paddings, self.mode, value=self.constant_values, data_format=data_format) def correct_paddings(self, in_shape, paddings, data_format): if in_shape == 3 and data_format == 'NLC': correct_output = [paddings[1][0], paddings[1][1]] elif in_shape == 4 and data_format == 'NHWC': correct_output = [paddings[2][0], paddings[2][1], paddings[1][0], paddings[1][1]] elif in_shape == 5 and data_format == 'NDHWC': correct_output = [ paddings[3][0], paddings[3][1], paddings[2][0], paddings[2][1], paddings[1][0], paddings[1][1] ] else: raise NotImplementedError('Does not support channels first') return correct_output
The text was updated successfully, but these errors were encountered:
No branches or pull requests
New Issue Checklist
Issue Description
[INSERT DESCRIPTION OF THE PROBLEM]
Reproducible Code
[INSERT CODE HERE]
The text was updated successfully, but these errors were encountered: