-
Notifications
You must be signed in to change notification settings - Fork 121
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
Problem on running with fdtd.set_backend("torch") #66
Comments
same issue with the |
Appears to be caused by pr #63 |
Hi everyone. My apologies for taking so long to fix this. The fix is now available in fdtd>=0.3.3. |
Sorry, but i still cant get the examples to work properly, using
|
version 0.3.4 should fix the issue |
please tell me if im doing something wrong here, but it still does not work?
|
Hi, my apologies... I don't have my computer with cuda GPU anymore so before I thought I could just debug by using the I spun up a VM with a GPU to debug this further. I can now confirm that all example notebooks now succesfully run with My apologies again for making you loose your time 🙂 |
still appears broken in 0.3.5, when using
|
which notebook is this in? Or is this in a custom notebook? |
this is in the lenses example |
**Hello,
When I execute my code with fdtd.set_backend("numpy"), it functions properly. However, switching to fdtd.set_backend("torch") leads to an error:**
Exception has occurred: TypeError
'torch.dtype' object is not callable
File "C:\Users\yo0003\moein\FDTD.py", line 73, in
grid[row:row+1,col:col+1,0] = fdtd.AbsorbingObject(permittivity=45.38,conductivity=0.77, name=str(row) + "," + str(col))
~~~~^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'torch.dtype' object is not callable
this is my code:
import torch
import fdtd
import numpy as np
from line_profiler import LineProfiler
import nibabel as nib
import matplotlib.pyplot as plt
device = torch.device("cpu")
Load the MNC file
mnc_img = nib.load('C:\Users\yo0003\moein\MATLAB_DRIVE\Matlab\subject04.mnc')
Get the data as a numpy array
data = mnc_img.get_fdata()
pic=20*data[250,:,:]
pic = np.pad(pic, ((10, 10), (10, 10)), mode='constant', constant_values=0)
for i in range(len(pic[:,1])):
for j in range(len(pic[1,:])):
if pic[i,j]==160:
pic[i,j]=20
pic=pic[::4,::4]
plt.imshow(pic)
plt.show()
pic = np.pad(pic, ((40, 40), (40, 40)), 'constant', constant_values=((0, 0), (0, 0)))
Set FDTD backend to CPU
fdtd.set_backend("torch")
Create a 2D grid with a single layer in the z-direction
Lx=len(pic[:,1])
Ly=len(pic[1,:])
freq=1e9
landa=3e8/freq
grid = fdtd.Grid(shape=(Lx, Ly, 1), grid_spacing=0.1*landa)
Brain=np.zeros((Lx, Ly,2))
# Add a light source
grid[20, 20, 0] = fdtd.PointSource(period=landa/3e8, name="source")
#*********************************************************
avg
#*********************************************************
loc=np.where(pic==120)
try:
# Your problematic code here, e.g.:
grid[40:50,50:60,0] = fdtd.Object(permittivity=45)
except Exception as e:
print("Error:", str(e))
for row, col in zip(*loc):
grid[row:row+1,col:col+1,0] = fdtd.AbsorbingObject(permittivity=45.38,conductivity=0.77, name=str(row) + "," + str(col))
The text was updated successfully, but these errors were encountered: