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
| dictionary_of_lists = df.to_dict(orient='list') | |
| total_size = 0 | |
| total_size += sys.getsizeof(dictionary_of_lists) | |
| for key in dictionary_of_lists.keys(): | |
| total_size += sys.getsizeof(key) | |
| total_size += sys.getsizeof(dictionary_of_lists[key]) | |
| for item in dictionary_of_lists[key]: | |
| total_size += sys.getsizeof(item) | |
| print(f'{total_size:,} B') |
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
| import sys | |
| total_size = 0 | |
| total_size += sys.getsizeof(list_of_dictionaries) | |
| for dictionary in list_of_dictionaries: | |
| total_size += sys.getsizeof(dictionary) | |
| for key, value in zip(dictionary.keys(), dictionary.values()): | |
| total_size += sys.getsizeof(key) | |
| total_size += sys.getsizeof(value) |
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
| import pandas as pd | |
| df = pd.DataFrame(list_of_dictionaries) | |
| mem = df.memory_usage(index=True, deep=True) | |
| total_size = sum(mem) | |
| print(f'{total_size:,} B') | |
| print(f'{total_size/1000000:.2f} MB') |
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
| import random | |
| random.seed(123) | |
| breeds = [ | |
| 'German Shepherd', | |
| 'Golden Retriever', | |
| 'Siberian Husky', | |
| 'Japanese Spitz', | |
| 'Sleeping Whippets', | |
| 'Samoyed', |
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
| transformable_obj.transform(lambda x: pickle.dumps(x, protocol=4)) |
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
| class MetaflowTask(object): | |
| ... | |
| def run_step(self, | |
| step_name, | |
| run_id, | |
| task_id, | |
| origin_run_id, | |
| input_paths, |
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
| $> python flow.ipynb run | |
| Network( | |
| (fc1): Linear(in_features=2, out_features=2, bias=True) | |
| (fc2): Linear(in_features=2, out_features=1, bias=True) | |
| ) | |
| Parameter containing: | |
| tensor([[-0.6120, -0.6511], | |
| [-0.3616, -0.3564]], requires_grad=True) | |
| Parameter containing: |
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
| # flow.ipynb | |
| from metaflow import Flow | |
| from inputs import inputs | |
| flow = Flow('ExperimentalPyTorchFlow') | |
| run = flow.latest_successful_run | |
| print(run['a'].task.data.model) | |
| for param in run['a'].task.data.model.parameters(): |
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
| $> python flow.py run | |
| Network( | |
| (fc1): Linear(in_features=2, out_features=2, bias=True) | |
| (fc2): Linear(in_features=2, out_features=1, bias=True) | |
| ) | |
| tensor([[-0.6120, -0.6511], | |
| [-0.3616, -0.3564]]) | |
| tensor([ 0.1328, -0.3496]) | |
| tensor([[0.4353, 0.4610]]) |
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
| # flow.py | |
| from metaflow import FlowSpec, step, Parameter | |
| from Network import Network | |
| from inputs import inputs | |
| class ExperimentalPyTorchFlow(FlowSpec): | |
| @step | |
| def start(self): | |
| self.model = Network() |
NewerOlder