Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Gin provides a lightweight configuration framework for Python
| Date | Stars |
|---|---|
| 2026-07-24 | 2153 |
| 2026-07-25 | 2153 |
| 2026-07-28 | 2153 |
| 2026-07-30 | 2153 |
| 2026-08-06 | 2153 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# Gin Config
**Authors**: Dan Holtmann-Rice, Sergio Guadarrama, Nathan Silberman
**Contributors**: Oscar Ramirez, Marek Fiser
<!---->
Gin provides a lightweight configuration framework for Python, based on
dependency injection. Functions or classes can be decorated with
`@gin.configurable`, allowing default parameter values to be supplied from a
config file (or passed via the command line) using a simple but powerful syntax.
This removes the need to define and maintain configuration objects (e.g.
protos), or write boilerplate parameter plumbing and factory code, while often
dramatically expanding a project's flexibility and configurability.
Gin is particularly well suited for machine learning experiments (e.g. using
TensorFlow), which tend to have many parameters, often nested in complex ways.
This is not an official Google product.
## Table of Contents
[TOC]
## Basic usage
This section provides a high-level overview of Gin's main features, ordered
roughly from "basic" to "advanced". More details on these and other features can
be found in the [user guide].
[user guide]: https://github.com/google/gin-config/tree/master/docs/index.md
### 1. Setup
Install Gin with pip:
```shell
pip install gin-config
```
Install Gin from source:
```shell
git clone https://github.com/google/gin-config
cd gin-config
python -m setup.py install
```
Import Gin (without TensorFlow functionality):
```python
import gin
```
Import additional TensorFlow-specific functionality via the `gin.tf` module:
```python
import gin.tf
```
Import additional PyTorch-specific functionality via the `gin.torch` module:
```python
import gin.torch
```
### 2. Configuring default values with Gin (`@gin.configurable` and "bindings")
At its most basic, Gin can be seen as a way of providing or changing default
values for function or constructor parameters. To make a function's parameters
"configurable", Gin provides the `gin.configurable` decorator:
```python
@gin.configurable
def dnn(inputs,
num_outputs,
layer_sizes=(512, 512),
activation_fn=tf.nn.relu):
...
```
This decorator registers the `dnn` function with Gin, and automatically makes
all of its parameters configurable. To set ("bind") a value for the
`layer_sizes` parameter above within a ".gin" configuration file:
```python
# Inside "config.gin"
dnn.layer_sizes = (1024, 512, 128)
```
Bindings have syntax `function_name.parameter_name = value`. All Python literal
values are supported as `value` (numbers, strings, lists, tuples, dicts). Once
the config file has been parsed by Gin, any future calls to `dnn` will use the
Gin-specified value for `layer_sizes` (unless a value is explicitly provided by
the caller).
Classes can also be marked as configurable, in which case the configuration
applies to constructor parameters:
```python
@gin.configurable
class DNN(object):
# Constructor parameters become configurable.
def __init__(self,
num_outputs,
layer_sizes=(512, 512),
activation_fn=tf.nn.relu):
...
def __call__(inputs):
...
```
Within a config file, the class name is used when binding values to constructor
parameters:
```python
# Inside "config.gin"
DNN.layer_sizes = (1024, 512, 128)
```
Finally, after defining or importing all configurable classes or functions,
parse your config file to bind your configurations (to also permit multiple
config files and command line overrides, see
[`gin.parse_config_files_and_bindings`][multiple files]):
```python
gin.parse_config_file('config.gin')
```
Note that no other changes are required to the Python code, beyond adding the
`gin.configurable` decorator and a call to one of Gin's parsing functions.
[multiple files]: https://github.com/google/gin-config/tree/master/docs/index.md#experiments-with-multiple-gin-files-and-extra-command-line-bindings
### 3. Passing functions, classes, and instances ("configurable references")
In addition to accepting Python literal valuExcerpt of 15,908 characters
Read on GitHub50
Sergio Guadarrama · Google · United States
25
13
5
Yilei · United States
4
Copybara Service · @google
4
Hana Joo · https://www.linkedin.com/in/hana-joo-6a0379127/ · Germany
2
2
Rebecca Chen
2
Matej Aleksandrov · Google · Germany
2
Eric Jang
1
Peter Hawkins · Google
1
1
Matt Watson · Google · United States
1
vfdev · @openteams-ai
1
Toby Boyd · @tensorflow
1
Adam Roberts · @google · United States
1
1
1
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:8b91f9fb7382d56e, topic:tensorflow