Meta-Faster-R-CNN icon indicating copy to clipboard operation
Meta-Faster-R-CNN copied to clipboard

Question about how to design dataset

Open Simon-Stma opened this issue 3 years ago • 1 comments

I would like to ask again, my dataset has more small targets (remote sensing dataset), and the size difference between different objects is large (and after referring to the VOC dataset, I found that the target in the original map is a larger proportion, which is different from my dataset), I choose Novel class to contain smaller objects and larger objects (more robust). But in the process of meta-training, no matter how I adjust the parameters, there is still a normal map of Base class and almost 0 map of Novel class, maybe it is not the problem of parameters, but my support size is 320x320 by default, should I reduce this value to better support meta-training? What is a better suggestion to solve this problem?

Simon-Stma avatar Oct 18 '22 14:10 Simon-Stma

Hi Lukas! Thanks for your report :) Yes, this might cause a problem since the Parameters are in the param_like_sections attribute. Could you give a small example? I suspect you could simply change this behaviour by subclassing the DocstringProcessor and putting the 'Parameters' in the text_sections attribute:

class DocstringProcessorWithBlanks(DocstringProcessor):

    param_like_sections = [s for s in DocstringProcessor.param_like_sections 
                           if s != 'Parameters']

    text_sections = ['Parameters'] + DocstringProcessor.text_sections

Or simply put all param_like_sections into the text_sections:

class DocstringProcessorWithBlanks(DocstringProcessor):

    param_like_sections = []

    text_sections = DocstringProcessor.text_sections + \
        DocstringProcessor.param_like_sections

Chilipp avatar Jul 11 '19 15:07 Chilipp

Thanks for the quick reply, Philipp!

Haha, sorry should have directly tried to strip it down, then my question would have been more specific...

So, as it turns out for simple functions blank lines are fine. However, in class methods blank lines don't work.

Example just with functions

Code

import docrep

docstrings = docrep.DocstringProcessor()

@docstrings.get_sectionsf('do_something')
@docstrings.dedent
def do_something(a, b):
    """
    Add two numbers

    Parameters
    ----------
    a: int
        The first number
        
    b: int
        The second number

    Returns
    -------
    int
        `a` + `b`"""
    return a + b


@docstrings.dedent
def do_more(c, *args, **kwargs):
    """
    Add two numbers and multiply it by c

    Parameters
    ----------
    c: int
        multiplication parameter
        
    %(do_something.parameters)s

    Returns
    -------
    int
        (`a` + `b`) * c"""
    return do_something(*args, **kwargs) * c

print(do_more.__doc__)

Output as desired

Add two numbers and multiply it by c

Parameters
----------
c: int
    multiplication parameter
    
a: int
    The first number
    
b: int
    The second number

Returns
-------
int
    (`a` + `b`) * c

Example using a class and method docstrings

Code

import docrep

docstrings = docrep.DocstringProcessor()

class A:
    @docstrings.get_sectionsf('do_something')
    @docstrings.dedent
    def do_something(a, b):
        """
        Add two numbers

        Parameters
        ----------
        a: int
            The first number

        b: int
            The second number

        Returns
        -------
        int
            `a` + `b`"""
        return a + b


    @docstrings.dedent
    def do_more(c, *args, **kwargs):
        """
        Add two numbers and multiply it by c

        Parameters
        ----------
        c: int
            multiplication parameter

        %(do_something.parameters)s

        Returns
        -------
        int
            (`a` + `b`) * c"""
        return do_something(*args, **kwargs) * c
    
a = A

print(a.do_more.__doc__)

Output: parameter b missing in printed docstring

Add two numbers and multiply it by c

Parameters
----------
c: int
    multiplication parameter

a: int
    The first number

Returns
-------
int
    (`a` + `b`) * c

lukashergt avatar Jul 11 '19 16:07 lukashergt

Both of your suggestions seem to work. Thanks, Philipp, that way I can keep my blank lines.

lukashergt avatar Jul 11 '19 16:07 lukashergt

Both of your suggestions seem to work.

Great 😄

So, as it turns out for simple functions blank lines are fine. However, in class methods blank lines don't work.

This is weird because actually the DocstringProcessor does not care whether it is a method or a function. I'll have a look into it and until then, we should keep this issue open.


As a little comment: the sections in the text_sections attribute assume that they end either by the next section or the end of the docstring. Therefore something like

def func(a=1):
    """
    An awesome function

    Parameters
    ----------
    a: int
        A parameter

    And here we have a paragraph that has nothing to 
    do with the Parameters section
    """

will cause problems if you have the 'Parameters' in the text_sections attribute.

Chilipp avatar Jul 11 '19 16:07 Chilipp

sections in the text_sections attribute assume that they end either by the next section or the end of the docstring

Good to know, I'll look out for that, but I guess typically this won't be an issue as the parameters section usually is followed by the results section.

lukashergt avatar Jul 11 '19 17:07 lukashergt

FYI: I am currently using this 'bug' as a feature. If I want to stop certain parameters from being inherited by subclasses I but them after a line break. This way I can re-define those specific parameters in subclasses without having duplicates (or without having the deal with removing them from the docrep dict).

This pertains to the feature request I just posted (issue #16)

jgostick avatar Mar 14 '20 16:03 jgostick