Skip to content

Commit

Permalink
Merge pull request #58 from kc-ml2/DEV/main
Browse files Browse the repository at this point in the history
Dev/main
  • Loading branch information
yonghakim authored Jul 21, 2023
2 parents 4acc95c + b4624cc commit 8387562
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
39 changes: 31 additions & 8 deletions meent/on_torch/modeler/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def ellipse(self, cx, cy, lx, ly, dx, dy, base, rotation_angle=0 * torch.pi / 18

def vector(self, layer_info, x64=True):

# TODO: activate and apply 'x64' option thru this function and connect to meent class.
if x64:
datatype = torch.complex128
perturbation = 1E-14
Expand All @@ -282,51 +283,73 @@ def vector(self, layer_info, x64=True):
for _ in range(100):
index = bisect_left(row_list, top_left[0].real, key=lambda x: x.real)
if len(row_list) > index and top_left[0] == row_list[index]:
top_left[0] = top_left[0] - (top_left[0] * perturbation)
if top_left[0] == 0:
top_left[0] = top_left[0] + perturbation
else:
# top_left[0] = top_left[0] - (top_left[0] * perturbation) # TODO: plus or minus?
top_left[0] = top_left[0] + (top_left[0] * perturbation)
else:
row_list.insert(index, top_left[0])
break
else:
print('WARNING: Overlapping of the objects in modeling is too complicated. Backprop may not work as expected.')
print('WARNING: Vector modeling has unexpected case. Backprop may not work as expected.')
index = bisect_left(row_list, top_left[0].real, key=lambda x: x.real)
row_list.insert(index, top_left[0])

# bottom_right[0]
for _ in range(100):
index = bisect_left(row_list, bottom_right[0].real, key=lambda x: x.real)
if len(row_list) > index and bottom_right[0] == row_list[index]:
bottom_right[0] = bottom_right[0] + (bottom_right[0] * perturbation)
# if bottom_right[0] == 0:
# bottom_right[0] = bottom_right[0] + perturbation
# else:
# # bottom_right[0] = bottom_right[0] + (bottom_right[0] * perturbation)
# bottom_right[0] = bottom_right[0] - (bottom_right[0] * perturbation)

# bottom_right[0] = bottom_right[0] + (bottom_right[0] * perturbation)
bottom_right[0] = bottom_right[0] - (bottom_right[0] * perturbation)
else:
row_list.insert(index, bottom_right[0])
break
else:
print('WARNING: Overlapping of the objects in modeling is too complicated. Backprop may not work as expected.')
print('WARNING: Vector modeling has unexpected case. Backprop may not work as expected.')
index = bisect_left(row_list, bottom_right[0].real, key=lambda x: x.real)
row_list.insert(index, bottom_right[0])

# top_left[1]
for _ in range(100):
index = bisect_left(col_list, top_left[1].real, key=lambda x: x.real)
if len(col_list) > index and top_left[1] == col_list[index]:
top_left[1] = top_left[1] - (top_left[1] * perturbation)
if top_left[1] == 0:
top_left[1] = top_left[1] + perturbation
else:
# top_left[1] = top_left[1] - (top_left[1] * perturbation)
top_left[1] = top_left[1] + (top_left[1] * perturbation)
else:
col_list.insert(index, top_left[1])
break
else:
print('WARNING: Overlapping of the objects in modeling is too complicated. Backprop may not work as expected.')
print('WARNING: Vector modeling has unexpected case. Backprop may not work as expected.')
index = bisect_left(col_list, top_left[1].real, key=lambda x: x.real)
col_list.insert(index, top_left[1])

# bottom_right[1]
for _ in range(100):
index = bisect_left(col_list, bottom_right[1].real, key=lambda x: x.real)
if len(col_list) > index and bottom_right[1] == col_list[index]:
bottom_right[1] = bottom_right[1] + (bottom_right[1] * perturbation)
# if bottom_right[1] == 0:
# bottom_right[1] = bottom_right[1] + perturbation
# else:
# # bottom_right[1] = bottom_right[1] + (bottom_right[1] * perturbation)
# bottom_right[1] = bottom_right[1] - (bottom_right[1] * perturbation)

# bottom_right[1] = bottom_right[1] + (bottom_right[1] * perturbation)
bottom_right[1] = bottom_right[1] - (bottom_right[1] * perturbation)
else:
col_list.insert(index, bottom_right[1])
break
else:
print('WARNING: Overlapping of the objects in modeling is too complicated. Backprop may not work as expected.')
print('WARNING: Vector modeling has unexpected case. Backprop may not work as expected.')
index = bisect_left(col_list, bottom_right[1].real, key=lambda x: x.real)
col_list.insert(index, bottom_right[1])

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
setup(
name='meent',
version='0.9.4',
version='0.9.5',
url='https://github.com/kc-ml2/meent',
author='KC ML2',
author_email='[email protected]',
Expand Down

0 comments on commit 8387562

Please sign in to comment.