jankrepl / mildlyoverfitted Goto Github PK
View Code? Open in Web Editor NEWPaper implementations from scratch and machine learning tutorials
License: MIT License
Paper implementations from scratch and machine learning tutorials
License: MIT License
I tried to run this file https://github.com/jankrepl/mildlyoverfitted/blob/master/github_adventures/vision_transformer/verify.py to reproduce the result, the last assertion is not passed. The result from the official model and the custom model is not the same, eventhough the weights are exactly the same, im not sure why. Also, it used to work flawlessly, I suspect it is something to do with torch 2.0 (or maybe timm), but im not sure.
here is the quick runnable notebook to verify the issue
https://colab.research.google.com/drive/1sRyBTvqAMkTgmSWlBFpv79mj6Ir4aLOT?usp=sharing
Hey, the number of parameters in your custom model are not matching with nay of the model here?
https://pytorch.org/vision/stable/models/vision_transformer.html
Thank you for the codes and video explanation. I got the following issue while running the verify.py file. I could run custom.py without any error and I have installed python 3.9, PyTorch version 1.8.
I did all the verification related to the availability of the vit_base_patch16_384 patch in the vision_transformer.py file. This is the error I got.
Could you please help me to solve this issue?
mildlyoverfitted/github_adventures/gpt/model.py
Lines 73 to 78 in 94c7983
Containing minimal instructions on how to launch relevant scripts and reproduce the results. The videos should contain everything, however, why not to make it even easier:)
Hi,
Thanks for the video on MLP mixer using pytorch and flax. I am facing an error while running the code. I am sharing the code that I have written and the error I am getting:
class conv1dDepthWiseShared(nn.Module):
def __init__(self, hidden_dim, kernel_size, k):
super().__init__()
#same as input channels of our tensor
self.hidden_dim = hidden_dim
# K is any number representing the output features
self.weight_shared = nn.Parameter(torch.rand(k, 1, kernel_size,))
self.bias_shared = nn.Parameter(torch.rand(k))
def forward(self, x):
weight = self.weight_shared(self.hidden_dim, 1, 1)
bias = self.bias_shared.repeat(self.hidden_dim)
res = torch.nn.functional.conv1d(x, weight=weight, bias=bias, groups=self.hidden_dim)
return res
n_samples, hidden_dim, n_patches = 2, 16, 25
k = 7
x = torch.rand(n_samples, hidden_dim, n_patches)
module_conv = conv1dDepthWiseShared(hidden_dim, n_patches, k)
module_linear = nn.Linear(n_patches, k)
module_conv.weight_shared.data[:, 0, :] = module_linear.weight.data
module_conv.bias_shared.data[:] = module_linear.bias.data
out_conv = module_conv(x).reshape(n_samples, hidden_dim, k)
TypeError Traceback (most recent call last)
<ipython-input-50-310a54adf4b2> in <module>()
----> 1 out_conv = module_conv(x).reshape(n_samples, hidden_dim, k)
1 frames
<ipython-input-40-a54ec45a7e5a> in forward(self, x)
9
10 def forward(self, x):
---> 11 weight = self.weight_shared(self.hidden_dim, 1, 1)
12 bias = self.bias_shared.repeat(self.hidden_dim)
13 res = torch.nn.functional.conv1d(x, weight=weight, bias=bias, groups=self.hidden_dim)
TypeError: 'Parameter' object is not callable
Make life easier for those who start from fresh virtual environments.
In the meantime, git grep import
should not be too overwhelming.
Hi, thanks for the nice codes and videos.
If we create an instance of your custom ViT and then try to load the pre-trained weights it's not working and gives errors.
I find The code for the "Growing Neural Cellular Automata" video very nice and compact.
However, one small problem: the eval video, that is theoretically added to Tensorboard with the writer function, does not seem to appear in Tensorboard after the training is complete (the way it does in the video).
For my personal use, I managed to retrieve it from Tensorboard with the EventAccumulator (so it is indeed produced in the back somewhere), but it would be nice for it to appear directly in the board.
Maybe it's because of something wrong from my end...
Hi Jan, thanks for the great work.
I found the answer so I am closing this. However, in case anyone has the same question and read this, it is from the following line:
p_c.data[:] = p_o.data
Hi there, I just found a similar issue as the #11
As you can see in the screen shot, based on the training on your code, i cannot control the step with the slider. It seems like there is no attribute "eval" has been written down.
I take the same traning steps and paramater setting as your youtube video. And I use the command line to invoke the tensorboard as below:
tensorboard --logdir=
I wonder if there is anything I missed. Thank you for your attention!
Please provide traing guide too. Any other sources about this are also welcome!
Good morning Mr Jan Krepl,
Cordial greeting,
After running DINO in PyTorch (https://www.youtube.com/ watch? V = psmMEWKk4Uk & list = PLDW9q3PQf5VI0X5ozC3dDgbld8S4lrBuL & index = 15) in google colab because I don't have a GPU, and I'm decreasing the amount of images for training and try, but I get the following error:
{'batch_size': 32, 'device': 'cpu', 'logging_freq': 1000, 'momentum_teacher': 0.9995, 'n_crops': 4,' n_epochs': 200, 'out_dim': 1024, 'tensorboard_dir': ' logs', 'clip_grad': 2.0, 'norm_last_layer': True, 'batch_size_eval': 64, 'teacher_temp': 0.04, 'student_temp': 0.1, 'pretrained': False, 'weight_decay': 0.4}
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/transforms.py:853: UserWarning: Argument interpolation should be of type InterpolationMode instead of int. Please, use InterpolationMode enum.
"Argument interpolation should be of type InterpolationMode instead of int."
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:481: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness / freeze if necessary.
cpuset_checked))
0% 0/8 [00:00 <?,? It / s] ^ C
I would appreciate a lot if you could help me, I have not been able to run the model. Thanks a lot.
I got quite intrigued after watching your YouTube video on OpenAI function calling and got your example.py code to play with. I wanted to see what it would do with an interesting ticker like HMNY. So I asked the following question and it barfed on start and end date. I thought I had unintentionally modified the code when I was perusing but a git diff
and a git st
both showed nothing had been modified:
# python example.py "If I bought 100 shares of HMNY stock on 2004-01-01, how much did I pay for them and how much are they worth today?"
2024-05-11 02:52:22,516 Calling get_price with symbol='HMNY' and date='2004-01-01'
2024-05-11 02:52:25,216 Calling get_price with symbol='HMNY' and date='2024-05-11'
2024-05-11 02:52:29,333
1 Failed download:
2024-05-11 02:52:29,333 ['HMNY']: Exception('%ticker%: Invalid input - start date cannot be after end date. startDate = 1715400000, endDate = 1715395945')
Traceback (most recent call last):
File "/root/source/mildlyoverfitted/mini_tutorials/openai_function_calling/example.py", line 105, in <module>
output = str(get_price(**kwargs))
File "/root/source/mildlyoverfitted/mini_tutorials/openai_function_calling/example.py", line 24, in get_price
return history["Close"].iloc[0].item()
File "/opt/openai-functions/lib/python3.10/site-packages/pandas/core/indexing.py", line 1191, in __getitem__
return self._getitem_axis(maybe_callable, axis=axis)
File "/opt/openai-functions/lib/python3.10/site-packages/pandas/core/indexing.py", line 1752, in _getitem_axis
self._validate_integer(key, axis)
File "/opt/openai-functions/lib/python3.10/site-packages/pandas/core/indexing.py", line 1685, in _validate_integer
raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds
So, I asked a different question and this time it didn't crash:
# python example.py "If I bought 100 shares of HMNY stock on 2004-01-01, how much did I pay for them and how much were they worth on 2018-07-31?"
2024-05-11 04:13:56,098 Calling get_price with symbol='HMNY' and date='2004-01-01'
2024-05-11 04:14:03,959 Calling get_price with symbol='HMNY' and date='2018-07-31'
2024-05-11 04:14:05,468 Calling calculate with a=2275, b=100 and op='mul'
2024-05-11 04:14:06,388 Calling calculate with a=0.4959999918937683, b=100 and op='mul'
********************************************************************************
['user', 'system', 'assistant', 'function', 'assistant', 'function', 'assistant', 'function', 'assistant', 'function', 'assistant']
********************************************************************************
You paid $2,275 for 100 shares of HMNY stock on January 1, 2004.
On July 31, 2018, each share of HMNY stock was worth $0.496.
Therefore, your 100 shares of HMNY stock were worth $49.60 on July 31, 2018.
This rather puzzled me so later on, I asked the same question that failed before but this time no crash:
# python example.py "If I bought 100 shares of HMNY stock on 2004-01-01, how much did I pay for them and how much are they worth today?"
2024-05-11 04:14:59,328 Calling get_price with symbol='HMNY' and date='2004-01-01'
2024-05-11 04:15:01,679 Calling get_price with symbol='HMNY' and date='2024-05-11'
2024-05-11 04:15:03,448 Calling calculate with a=2275, b=100 and op='mul'
2024-05-11 04:15:04,363 Calling calculate with a=0.00019999999494757503, b=100 and op='mul'
********************************************************************************
['user', 'system', 'assistant', 'function', 'assistant', 'function', 'assistant', 'function', 'assistant', 'function', 'assistant']
********************************************************************************
If you bought 100 shares of HMNY stock on 2004-01-01, you would have paid $2,275 for them.
As of today (2024-05-11), each share of HMNY stock is worth $0.0002. Therefore, your 100 shares would be worth $0.02.
It looks like OpenAI can be unstable at times...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.