Skip to content
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

I don't seem to be able to run the code correctly #23

Open
PandaK404 opened this issue Jun 15, 2023 · 1 comment
Open

I don't seem to be able to run the code correctly #23

PandaK404 opened this issue Jun 15, 2023 · 1 comment

Comments

@PandaK404
Copy link

Hello, I have the following problem when running the code and I need your help very much!

  1. After I clone the code and install the dependencies according to the tutorial (i.e. complete the following steps), I open jupyternotebook and then how to execute the code?
    图片

  2. I tried to run directly in vscode python . /datagen/gen_data.py, but the following error is reported
    图片

  3. After encountering the above error, I tried to create an hdf5 file using the command: touch /xxx/test/deep-route/data/layout_data.hdf5, after executing python . /datagen/gen_data.py still reported the same error, and I created the hdf5 file disappeared.

I've tried many things and still can't solve the problem, hope to get your help!

@emillal
Copy link

emillal commented Jul 10, 2024

There was an issue with the genData function. An issue related with the directory

The rectified function code is as below:

###########################################

def genData(N=10, H=32, W=32, pin_range=(2, 6)):

# 8 layout layers for now
C = 8

data_dir = os.getcwd() + "/data/"
# Ensure the directory exists
if not os.path.exists(data_dir):
    os.makedirs(data_dir)

if os.path.exists(data_dir):
    for file in os.listdir(data_dir):
        if file.endswith(".hdf5"):
            os.remove(data_dir+file)
else:
    os.makedirs(data_dir)

data = h5py.File(data_dir + "layout_data.hdf5", 'w')

# numpy arrays no longer needed; use HDF5 instead
#X = np.zeros([N, 1, H, W], dtype = np.int8)
#Y = np.zeros([N, C, H, W], dtype = np.int8)

X = data.create_dataset("X", shape=(N, 1, H, W), dtype='uint8', compression='lzf', chunks=(1, 1, H, W))
Y = data.create_dataset("Y", shape=(N, C, H, W), dtype='uint8', compression='lzf', chunks=(1, 1, H, W))

# Set physical size represented by HxW pixels
microns = 11.0    # To have balanced dataset covering from m3 to m6 (based on resistance plots from resistance_vs_distance.ipynb)
microns_per_xpixel = microns/W
microns_per_ypixel = microns/H

# Layer map
l_map = {
    # Pins
    'pin' : 0,
    
    # Vias
    'via3' : 2,
    'via4' : 4,
    'via5' : 6,
    
    # Vertical tracks
    'm3' : 1,
    'm5' : 5,
  
    # Horizontal tracks
    'm4' : 3,
    'm6' : 7
}

#m3_m4 = m5_m4 = m5_m6 = 0

n = 0
print_every = 5000

while n < N:
    # Randomly select number of pins from given range
    # Uniform distribution over pin range
    nPins = np.random.randint(*pin_range)
    # Non-uniform distribution (skewed exponentially towards smaller number of pins)
    #p_range = np.array(range(*pin_range))
    #p = np.exp(-p_range) / np.sum(np.exp(-p_range))
    #nPins = np.random.choice(p_range, p=p)
    
    # Randomly pick x and y co-ords for nPins from [0, W) and [0, H) pixels
    x_pins = np.random.randint(W, size=nPins)
    y_pins = np.random.randint(H, size=nPins)
    
    max_xlen = (max(x_pins) - min(x_pins)) * microns_per_xpixel   # length in um
    max_ylen = (max(y_pins) - min(y_pins)) * microns_per_ypixel   # length in um
    
    # Corner case when pins overlap each other (invalid case)
    # Bug fix for https://github.com/sjain-stanford/RouteAI/issues/4
    if (max_xlen == 0) and (max_ylen == 0):
        continue

    # Draw pins on layer 'pin (m2)' of both X (data) and Y (labels)
    X[n] = drawPins(X[n], x_pins, y_pins, l_map)
    Y[n] = drawPins(Y[n], x_pins, y_pins, l_map)
    
    # Add routes to Y (labels)
    x_wire, y_wire = selectWireClass(max_xlen, max_ylen)
    Y[n] = drawRoutes(Y[n], x_pins, y_pins, max_xlen, max_ylen, x_wire, y_wire, l_map)
    
    n += 1
    
    if (n % print_every == 0):
        print("Finished generating %d samples." %(n))
    
    #if x_wire == 'm4' and y_wire == 'm3':
    #    m3_m4 += 1
    #elif x_wire == 'm4' and y_wire == 'm5':
    #    m5_m4 += 1
    #elif x_wire == 'm6' and y_wire == 'm5':
    #    m5_m6 += 1
    #else:
    #    print(x_wire, y_wire)
    
#print(m3_m4, m5_m4, m5_m6)

# Storing as .npy using np.save -> Issue: RAM out of memory, disk memory limitation   
#data_dir = os.getcwd() + '/data/'    
#if os.path.exists(data_dir):
#    for file in os.listdir(data_dir):
#        if file.endswith(".npy"):
#            os.remove(data_dir+file)
#else:
#    os.makedirs(data_dir)
#X_save = data_dir + 'X_save.npy'
#Y_save = data_dir + 'Y_save.npy'    
#np.save(X_save, X, allow_pickle=False)
#np.save(Y_save, Y, allow_pickle=False)

print("Dataset generated as follows:")
for ds in data:
    print(ds, data[ds])

#############################################

Screenshot from 2024-07-10 13-31-08

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

No branches or pull requests

2 participants