lf1-io / padl

Functional deep learning
Apache License 2.0
106 stars 4 forks source link

368 print statement limited column #376

Closed jasonkhadka closed 2 years ago

jasonkhadka commented 2 years ago

Description

Fixes #368

@transform
class Generator:
    def __init__(self, channel_number=96, 
                 network_depth=5,
                 in_channels=50, 
                 convolution_type='regular', 
                 image_channels=3):
        self.channel_number = channel_number
        self.network_depth = network_depth
        self.convolution_type = convolution_type
        self.image_channels = image_channels

    def __call__(self, input):
        return input

f = identity - 'f'

gen = Generator(channel_number=96, 
                 network_depth=5,
                 in_channels=50, 
                 convolution_type='regular', 
                image_channels=3)

1. Full args

comp = (
    f
    >> batch
    >> f
    >> gen
)

Compose - "comp":

      │
      ▼ args
   0: Identity(-?-)                                                                                              
      │
      ▼ args
   1: Batchify(dim=0)                                                                                            
      │
      ▼ args
   2: Identity(-?-)                                                                                              
      │
      ▼ input
   3: Generator(channel_number=96, network_depth=5, in_channels=50, convolution_type='regular', image_channels=3)

2. Shortened args

comp = (
    f
    >> batch
    >> f + f
    >> gen

)
Compose - "comp":

      │
      ▼ args
   0: Identity(-?-)                                     
      │
      ▼ args
   1: Batchify(dim=0)                                   
      └────────────────────────────────────────────────────┐
      │                                                    │
      ▼ args                                               ▼ args
   2: Identity(-?-)                                      + Identity(-?-)
      │
      ▼ input
   3: Generator(channel_number=96, network_depth=5, ...)

3. Even shorter

comp = (
    f
    >> batch
    >> f + f + f
    >> gen

)

Compose - "comp":

      │
      ▼ args
   0: Identity(-?-)                    
      │
      ▼ args
   1: Batchify(dim=0)                  
      └───────────────────────────────────────────────────┐
      └───────────────────────────────────┐               │
      │                                   │               │
      ▼ args                              ▼ args          ▼ args
   2: Identity(-?-)                     + Identity(-?-) + Identity(-?-)
      │
      ▼ input
   3: Generator(channel_number=96, ...)