383. Abstraction and Reasoning Challenge | abstraction-and-reasoning-challenge
首先,非常感谢 François Chollet 和 Kaggle 团队组织了这场精彩的比赛。
对我来说,这是一场非常有趣且充满创意的比赛。我有整整一个月的时间分数一直是 1(满分)哈哈。
我的解决方案与大家讨论过的 DSL(领域特定语言)方法类似。
所有的训练代码和测试/评估代码都通过具有以下接口的 Python 方法进行处理。
def converter(inp, objects, c) 返回 objects
def merger(objects, c):
我定义了 100 多个转换器(converter)方法和 10 个合并器(merger)方法。
例如,一个任务可能会通过以下步骤解决:
我有旋转、填充、翻转、移动、画线等多种类型的转换器,以及 or_merge、and_merge、select_biggest_object 等更多的合并器。
大致就是这样。
我很期待看到比我的想法更有创意的点子和解决方案 :)
还有一点说明,在第一个月我尝试了基于 CNN 的图像生成模型。但由于我们的训练数据太少,所以没有奏效。
def identify_rec2(y, x, a, visited, c, rect):
if visited[y + 1][x + 1]:
return
visited[y + 1][x + 1] = True
if a[y][x] == c.bg_color:
return
if y < rect.y1:
rect.y1 = y
if y > rect.y2:
rect.y2 = y
if x < rect.x1:
rect.x1 = x
if x > rect.x2:
rect.x2 = x
identify_rec2(y + 1, x + 1, a, visited, c, rect)
identify_rec2(y + 1, x, a, visited, c, rect)
identify_rec2(y, x + 1, a, visited, c, rect)
identify_rec2(y - 1, x - 1, a, visited, c, rect)
identify_rec2(y + 1, x - 1, a, visited, c, rect)
identify_rec2(y - 1, x + 1, a, visited, c, rect)
identify_rec2(y - 1, x, a, visited, c, rect)
identify_rec2(y, x - 1, a, visited, c, rect)
def identify_greedy(inp, objects, c):
if len(objects) != 1:
raise SkipException
return objects
a = objects[0].data
height, width = a.shape
if height > 30 and width > 30:
raise SkipException
return objects
visited = init_visited(height, width)
objs = []
for y in range(height):
for x in range(width):
if visited[y + 1][x + 1]:
continue
if a[y][x] == c.bg_color:
visited[y + 1][x + 1] = True
continue
if not visited[y + 1][x + 1]:
rec = Rect(y,y, x, x)
identify_rec2(y, x, a, visited, c, rec)
obj = Object(a)
obj.rectangle = (rec.y1, rec.y2, rec.x1, rec.x2)
objs.append(obj)
if len(objs) == 0