Skip to content

CNN weights example #730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

CNN weights example #730

wants to merge 2 commits into from

Conversation

clewis7
Copy link
Member

@clewis7 clewis7 commented Feb 17, 2025

WIP!

Started playing around with a simple CNN in pytorch to visualize the weights as the model is training using the MNIST dataset

image

The weights are definitely being updated every epoch, but the plot will not update until the last training epoch is done...not sure why

Another thing of note, pytorch tensors cannot directly be used with fpl right now because

File [~/repos/fastplotlib/fastplotlib/graphics/_features/_image.py:101](http://localhost:8888/lab/tree/examples/fastplotlib/graphics/_features/_image.py#line=100), in TextureArray._fix_data(self, data)
     95     raise ValueError(
     96         "image data must be 2D with or without an RGB(A) dimension, i.e. "
     97         "it must be of shape [rows, cols], [rows, cols, 3] or [rows, cols, 4]"
     98     )
    100 # let's just cast to float32 always
--> 101 return data.astype(np.float32)

AttributeError: 'Tensor' object has no attribute 'astype'

@kushalkolar
Copy link
Member

Are you trying to update a graphic in a for loop? You can't do this right now, see the discussions post. For now we can use zmq or see rendercanvas and try to expose the ondemand rendering mode in fpl

Torch tensors can't be used directly but if you do np.asarray it will not make a copy

@clewis7
Copy link
Member Author

clewis7 commented Feb 17, 2025

Torch tensors can't be used directly but if you do np.asarray it will not make a copy

Even when I do np.asarray I still get issues that the arrays are on different devices

TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

Are you trying to update a graphic in a for loop? You can't do this right now, see the discussions post. For now we can use zmq or see rendercanvas and try to expose the ondemand rendering mode in fpl

I was trying to use for loop, I will try using zmq for now

@kushalkolar
Copy link
Member

Yea you need to send to cpu

@clewis7
Copy link
Member Author

clewis7 commented Feb 17, 2025

Okay, still a bit messy and inelegant...but progress

Right now I have the weights updating after every training epoch

net_weights.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy