Teddy-XiongGZ / HIRES-baselines

0 stars 0 forks source link

Variables in Parameter class #2

Open Lukeming-tsinghua opened 3 years ago

Lukeming-tsinghua commented 3 years ago

Why not try using Class Variable here? Variables in __init__ function will be created after initializing a class instance, while Class Variable could be used even before initialization and more space-saving.

https://github.com/Teddy-XiongGZ/RelationExtraction/blob/8854a1f075116fe5584f4f9afc482a48aca99516/DataETL-dev/src/parameters.py#L1

Teddy-XiongGZ commented 3 years ago

You mean the class Variable in torch.autograd? I'm a little confused because I think there is no need for backpropagation.

Lukeming-tsinghua commented 3 years ago

You mean the class Variable in torch.autograd? I'm a little confused because I think there is no need for backpropagation.

Class Variable is a term in python, opposite to Instance Variable. Please refer to following codes :) BTW, class names in python are expected to be CamelCase (You should name it Class Parameters) so that it is easy to distinguish class name and instance (usually parameters = Parameters() ). Function names and variable names are expected to be under_score_case.

class parameters:
        random_seed = 0
        lr = 0.0005
        batch_size = 32
        max_epoch = 40

# you can still use parameters in class parameters like this

random_seed = parameters.random_seed