Skip to main content

A Python package for generating data sets based on Hugh Perkins' TexRel (https://arxiv.org/abs/2105.12804)

Project description

texrelenv: TexRel-like environments for emergent language experiments

A Python package for generating data sets based on Hugh Perkins' TexRel.

3 example images of the data generated by this library

Getting started

You can install this package from pypi using

pip install texrelenv

See example usage below for how to use the package to generate data.

Example usage

Here is an example of how to generate 100 images based on some config options specified in a config.toml file.

Let's say you have a config.toml file that looks like the below. "grid" refers to the overall canvas of the image while "things" refers to the coloured objects that appear in images. The config options shown below are exhausted and are explained in the (Config options)[#Config options] section below

[things]
distinct_shapes = 9
distinct_colours = 9

[environment]
grid_size = 16
thing_size = 4
things_per_image = 5
hard_boundary = true
objects_can_overlap = false

[split]
hold_out_things = 0.2
hold_out_images = 0.0

A dataset can be created from the above config in the following way

from texrelenv import DataSet

data = DataSet(config_file="config.toml")

You could also pass all the config arguments as arguments when you instantiate the DataSet (they are all named the same).

Having instantiated the data set, you can generate some train images like this:

data.sample(100, 'train')

Or some test images like this:

data.sample(100, 'test')

Config options

Option Type Meaning
grid_size int The size of the square images generated, expressed as the length of the side of the square in pixels. Default is 16, for an easy drop-in replacement for MNIST-like data sets, use 28.
hard_boundary bool If true, shapes added to an image will always be fully visible. If false, they may partially be out of frame.
objects_can_overlap bool Can objects go in front of or behind one another? Default is false.
thing_size int How big are the coloured objects added to images? Expressed as the length of one side of the square canvas used to create the templates for these objects, which can also be thought of as the maximum size of an object.
distinct_shapes int
distinct_colours int blah
things_per_image int blah
rotate bool blah
flip bool blah
hold_out_things float blah
hold_out_images float blah

Contributing

To contribute to the project, please make sure you have poetry installed and before you start working on the code, set up a virtual environment, activate it and then run

poetry install

to install all dependencies including dependencies only required for development. Then update precommit hooks with

pre-commit install
pre-commit autoupdate

Pre-commit will help you to keep your code style in keeping with the rest of the project.

Please write tests for your code, store them in test/, and only commit code that passes the unit tests that already exist. You can run unit tests with

python -m unittest

(precommit will not run unit tests!)

Acknowledgements

We are hugely thankful to Hugh Perkins for coming up with the idea of TexRel in the first place, for creating the first version of PyTorch, and for doing various other cool stuff.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

texrelenv-0.1.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

texrelenv-0.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file texrelenv-0.1.1.tar.gz.

File metadata

  • Download URL: texrelenv-0.1.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.9.5 Darwin/24.1.0

File hashes

Hashes for texrelenv-0.1.1.tar.gz
Algorithm Hash digest
SHA256 da2d8a87be18380f13fc1aa3e82509134b783fde8b85f94bb42f28870c4de15f
MD5 6f5a07162d8783ef3d1a7eb3c9de2fd5
BLAKE2b-256 5c71d499e532bf9eed21d32d0242e8eb3b38caa04bc5b98e0dc04b481d641617

See more details on using hashes here.

File details

Details for the file texrelenv-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: texrelenv-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.9.5 Darwin/24.1.0

File hashes

Hashes for texrelenv-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba46f07ccb0c6baf99e359cf5b490de88a34921a15a73e1f72a749a56510d41b
MD5 7ef123be6fd0a1ae75701d65ff7be07d
BLAKE2b-256 c661ef335f8e910b7d822f4275806aa70c84b029d33f85555d9469ca28f3c126

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page