Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions gpu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import tensorflow as tf

# Disable all GPUs
tf.config.set_visible_devices([], "GPU")

# Verify that the GPU is disabled
print("Available GPUs:", tf.config.list_physical_devices("GPU"))

# Your TensorFlow code here


# import tensorflow as tf


# # Create a simple computation to verify GPU usage
# a = tf.constant([[1.0, 2.0], [3.0, 4.0]])
# b = tf.constant([[1.0, 1.0], [0.0, 1.0]])
# c = tf.matmul(a, b)

# print("\n\n")
# # Check if TensorFlow is using the GPU
# print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices("GPU")))
# print("Result of matrix multiplication:\n", c)
2 changes: 1 addition & 1 deletion simple.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"training_data":6.0,"evaluation_data":5.5}
{"training_data":None,"evaluation_data":100.0}
9 changes: 9 additions & 0 deletions src/biabduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
from load_data import Task, Tasks, evaluation_data, training_data
from logger import logger
from match_colored_objects import match_colored_objects
from match_two_objects_with_output import match_two_objects_with_output
from match_objects_in_grid import match_rectangular_objects_in_grid
from match_subgrids_in_lattice import match_subgrids_in_lattice
from objects import Object, display_multiple
from primitives import primitive_to_xform, translate_down_1, xform_identity
from split_mirrot_match import frame_split_and_mirror_xform


import tensorflow as tf
# turn off gpu
#tf.config.set_visible_devices([], "GPU")
print("Available GPUs:", tf.config.list_physical_devices("GPU"))



def filter_simple_xforms(task: Task, task_name: str):
examples = task.train
for example in examples:
Expand Down Expand Up @@ -60,6 +68,7 @@ def filter_complex_xforms(task: Task, task_name: str):
XformEntry(match_rectangular_objects_in_grid, 3),
XformEntry(inpainting_xform_no_mask, 2),
XformEntry(inpainting_xform_output_is_block, 2),
XformEntry(match_two_objects_with_output, 3),
] + (
[
XformEntry(inpainting_xform_with_mask, 2),
Expand Down
7 changes: 5 additions & 2 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
# task_name = "f9d67f8b.json" # maybe a mistake in the task

# task_name = "72ca375d.json"
# task_name = "0934a4d8.json"
task_name = "0934a4d8.json"

# task_name = "1e97544e.json"

# task_name = "6ecd11f4.json"


task_fractal = "8f2ea7aa.json" # fractal expansion
task_puzzle = "97a05b5b.json" # puzzle-like, longest in DSL (59 lines)

Expand Down Expand Up @@ -54,7 +57,7 @@
max_colors = 4

only_complex_examples = False
min_size = 23
min_size = 21
min_colors = 9

find_xform = True
Expand Down
44 changes: 44 additions & 0 deletions src/match_two_objects_with_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from typing import List, Optional

from bi_types import Example, Match, Object
from logger import logger
from objects import display_multiple, display
from visual_cortex import find_rectangular_objects
import config


def match_two_objects_with_output(
examples: List[Example[Object]],
task_name: str,
nesting_level: int,
) -> Optional[Match[Object, Object]]:
logger.info(
f"{' ' * nesting_level}match_two_objects_with_output examples:{len(examples)} task_name:{task_name} nesting_level:{nesting_level}"
)
for input, output in examples:
background_color = input.main_color(allow_black=True)
objects = input.detect_objects(
diagonals=True, background_color=background_color, multicolor=True
)
if len(objects) == 0:
return None
largest_object = max(objects, key=lambda o: o.area)
other_objects = [o for o in objects if o != largest_object]
if len(other_objects) < 1:
return None

if largest_object.size == input.size:
return None
if all(output.size != o.size for o in objects):
return None

if len(objects) <= 2:
return None

# display_multiple(
# [largest_object, other_object, output], title=f"objects:{len(objects)}"
# )

config.display_this_task = True

return None
Loading