0

what happens when we call super of an object in itself, like below

class DuelCNN(nn.Module):
    def __init__(self, output_size: int):
        super(DuelCNN, self).__init__()

i get that if we had 2 object like...

class A:
    def __init__(self):
        self.x = 1
class B:
    def __init__(self):
        super(A, self).__init__()

then B would have x=1

What does the super do in the example at the top?

i found that example i dont understand here, in case you want see.

https://github.com/jackapbutler/pong-dqn-rl/blob/main/pong_dqn_rl/dueling_qn.py

tgm_learn
  • 61
  • 7
  • 1
    It is *usual* for `super` to specify the same class, like in the top example, in 2.x. (In 3.x, the arguments are not needed at all, and are normally omitted). The bottom example is a hack, because `B` does not inherit from `A` in the first place. Please see the linked duplicate for an overview of how `super` works. – Karl Knechtel Sep 28 '22 at 17:38
  • Your second example is absolutely incorrect. I'm not sure why you thought `super` would work like that, but that is definitely not what the usage of `super` is supposed to look like, the first example is pretty canonical, it is calling the super class `__init__`. What do you *think* `super` is doing? – juanpa.arrivillaga Sep 28 '22 at 18:25
  • like calling the initializer of the object A in object B ,or copying the code of object A's initializer into object B... – tgm_learn Sep 29 '22 at 08:40

0 Answers0