Measuring processing time python
Measure processing time
..
..
Thank you.
www.marearts.com
Object of type float32 is not JSON serializable
Converting float to avoid error, refer to code:
..
..
Another solution is:
..
..
But in this case, json is saved as string.
Thank you.
www.marearts.com
rectangle, box face -> mosaic, pixelate
refer to mosaic function
..
..
Ex) result
Thank you.
www.marearts.com
Remove duplicated dict element in list, remove same dict element in tow list
refer to code:
..
..
Thank you.
www.marearts.com
python calculate intersect of union area between two box
refer to code:
..
..
Thank you
www.marearts.com
python yaml to dict
refer to code
..
..
> example output
{'batch_size': 1000, 'data_path': ['../npy/x_train_coin_eth.npy', '../npy/y_train_coin_eth.npy', '../npy/x_val_coin_eth.npy', '../npy/y_val_coin_eth.npy', '../npy/x_test_coin_eth.npy', '../npy/y_test_coin_eth.npy'], 'encoder_hidden_dims': [4, 2], 'input_dim': 5, 'input_seq': 128, 'learning_rate': 0.0001, 'num_LSTM': 2, 'num_layers': 1} <class 'dict'>Thank you.
www.marearts.com
'your model' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead.
I tired to save sub model in seq-to-seq model which is encoder part.
What I used for save and load is like follow code and I failed with error like title.
* Failed case
..
..
* error message
..
My solution is to use 'state_dict()' to save model.
Refer to bellow code which was solution for me.
..
..
Thank you.
www.marearts.com
opencv, cv2, rotate image & point
refer to code.
sample point is 100,100
firstly, I rotated image as 90 degree and point.
And compare origin image & pt where rotated point is placed in right position.
..
..
Thank you.
www.marearts.com
LSTM Autoencoder pytorch
Code
...
...
Test class and show summary
..
..
output
..
Refer to my ugly drawing
Thank you.
www.marearts.com
time-distributed dense (TDD, TimeDistributed) layer in PyTorch
refer to code:
..
..
Thank you.
www.marearts.com
torch repeat example
Refer to code
..
..
>>
input :torch.Size([100, 140, 5]), repeat:torch.Size([100, 140, 5]) input :torch.Size([100, 140, 5]), repeat:torch.Size([100, 1400, 5]) input :torch.Size([100, 140, 5]), repeat:torch.Size([100, 140, 50]) input :torch.Size([100, 140, 5]), repeat:torch.Size([1000, 140, 5])
Thank you.www.marearts.com
pytorch module list example
ex1)
..
ex2)
..
print module list
>
ModuleList( (0): Linear(in_features=10, out_features=10, bias=True) (1): Linear(in_features=10, out_features=10, bias=True) (2): Linear(in_features=10, out_features=10, bias=True) (3): Linear(in_features=10, out_features=10, bias=True) (4): Linear(in_features=10, out_features=10, bias=True) (5): Linear(in_features=10, out_features=10, bias=True) (6): Linear(in_features=10, out_features=10, bias=True) (7): Linear(in_features=10, out_features=10, bias=True) (8): Linear(in_features=10, out_features=10, bias=True) (9): Linear(in_features=10, out_features=10, bias=True) )
Warning: find_unused_parameters=True was specified in DDP constructor, but did not find any unused parameters. This flag results in an extra traversal of the autograd graph every iteration, which can adversely affect performance
Try #1
..
Try #2
..
Thank you.
pytorch lightning change checkpoints output dir and version str
Use "save_dir", "name", "version" params in pl_loggers function.
more detail : https://pytorch-lightning.readthedocs.io/en/stable/extensions/generated/pytorch_lightning.loggers.TensorBoardLogger.html
..
..
And you can retrieve what is my logging path by:
tb_logger.log_dir or self.logger.log_dir (in class)
> logs/no_default/my_version_2
Thank you.
www.marearts.com
🙇🏻♂️
Get google stock date using pandas.
refer to sample code
..
..
Thank you.
www.marearts.com
ModuleNotFoundError: No module named 'pandas_datareader'
Simply install package through pip
..
..
Thank you.
skip sanity val check in pytorch lightning
set trainer like this:







