Last active
January 17, 2022 18:22
-
-
Save remi-or/8c881d812c2451043e5483d3d4b522d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Any | |
from transformers import AutoModelForMaskedLM | |
roberta = AutoModelForMaskedLM.from_pretrained("roberta-large") | |
def visualize_children( | |
object : Any, | |
level : int = 0, | |
) -> None: | |
""" | |
Prints the children of (object) and their children too, if there are any. | |
Uses the current depth (level) to print things in a ordonnate manner. | |
""" | |
print(f"{' ' * level}{level}- {type(object).__name__}") | |
try: | |
for child in object.children(): | |
visualize_children(child, level + 1) | |
except: | |
pass | |
visualize_children(roberta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment