Skip to content

Missing properties and methods in both Layer and LayerArgs class #660

Closed

Description

@minhduc66532

I want to translate this class to C#:

class BilinearUpSampling2D(Layer):
    def __init__(self, size=(2, 2), data_format=None, **kwargs):
        super(BilinearUpSampling2D, self).__init__(**kwargs)
        self.data_format = normalize_data_format(data_format)
        self.size = conv_utils.normalize_tuple(size, 2, 'size')
        self.input_spec = InputSpec(ndim=4)

    def compute_output_shape(self, input_shape):
        if self.data_format == 'channels_first':
            height = self.size[0] * input_shape[2] if input_shape[2] is not None else None
            width = self.size[1] * input_shape[3] if input_shape[3] is not None else None
            return (input_shape[0],
                    input_shape[1],
                    height,
                    width)
        elif self.data_format == 'channels_last':
            height = self.size[0] * input_shape[1] if input_shape[1] is not None else None
            width = self.size[1] * input_shape[2] if input_shape[2] is not None else None
            return (input_shape[0],
                    height,
                    width,
                    input_shape[3])

    def call(self, inputs):
        input_shape = K.shape(inputs)
        if self.data_format == 'channels_first':
            height = self.size[0] * input_shape[2] if input_shape[2] is not None else None
            width = self.size[1] * input_shape[3] if input_shape[3] is not None else None
        elif self.data_format == 'channels_last':
            height = self.size[0] * input_shape[1] if input_shape[1] is not None else None
            width = self.size[1] * input_shape[2] if input_shape[2] is not None else None
        
        return tf.image.resize(inputs, [height, width], method=tf.image.ResizeMethod.BILINEAR)

    def get_config(self):
        config = {'size': self.size, 'data_format': self.data_format}
        base_config = super(BilinearUpSampling2D, self).get_config()
        return dict(list(base_config.items()) + list(config.items()))

But the problem is i can't find compute_output_shape() to override, no size and data_format property or something fimiliar in Layer class.

image

No compute_output_shape() method in sight:

image

And in the LayerArgs class there is no items() method:

image

Any ideas ? And thank you for all of our answer

Activity

  1. self-assigned this
    on Dec 7, 2020
  2. added
    enhancement
    on Dec 7, 2020
  3. Oceania2018 commented on Dec 7, 2020

    @Oceania2018
    Member

    @minhduc66532 Added virtual method ComputerOutputShape, will be available for 12/12/2020 release.

  4. minhduc66532 commented on Dec 7, 2020

    @minhduc66532
    Author

    Thank you, i hope it will available as soon as possible

  5. Oceania2018 commented on Dec 12, 2020

    @Oceania2018
    Member

    It's available on tensorflow.kears v0.2.0, please take a look and let's know if you need further functions.

  6. minhduc66532 commented on Dec 12, 2020

    @minhduc66532
    Author

    image
    image
    For some reason Layer class does not exist in Tensorflow.Keras.Layers anymore ?

  7. Oceania2018 commented on Dec 12, 2020

    @Oceania2018
    Member

    @minhduc66532 Please follow the example projects.

  8. minhduc66532 commented on Dec 13, 2020

    @minhduc66532
    Author

    Ahh ok, everything is working fine now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions