Skip to main content

keras GridSearch Cacheable

Descripción

Cuando está desarrollando un componente en KERAS y Tensorflow y requiere hacer búsqueda de parámetros mediante GridSearch puede ser muy tardado y requerir mucho reproceso al ejecutar su código.

Para dar solución a esto se creó el keras GridSearch Cacheable con el objetivo de extender las funcionalidades de cacheo de SK-Learn a KERAS.

Instalación

En Google Colaboratory:

Ejecute el siguiente fragmento de código

def downloadDriveFile(file_id,file_name,file_extension):
  !wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id='$file_id -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id="$file_id -O "$file_name"."$file_extension" && rm -rf /tmp/cookies.txt

downloadDriveFile("1G9uWCkxwyE-qISaYbXYtnM21wT1kz11X","CacheableKeras","py")
from cacheable_keras.cacheable import KerasCacheable
En General
TODO: Pendiente por agregar a pip

Uso

Extienda la clase en su componente:

from CacheableKeras import KerasCacheable

class YourComponent(BaseEstimator, TransformerMixin, KerasCacheable):
    def __init__(self, ...):

Nota: Este ejemplo es para un TransformerMixin perfectamente puede usarse en RegressorMixin o ClassifierMixin segun sea el objetivo de su componente.

Defina Funciones Personalizadas:

Puede decir las funciones que quiere que su modelo ejecute sobrescribiendo el método get_custom_objects así:

def get_custom_objects(self):
    return { 'custom_loss': self.custom_loss }

Nota: Este método debe retornar un diccionario { ‘function_name’ : self.reference_function } y la reference_function debe estar definida en YourComponent. En caso de necesitar más de una función personalizada agréguela al diccionario.

Personalice la configuración:

keras GridSearch Cacheable trabaja por defecto con TODOS los parámetros de entrada YourComponent. Sin embargo, si por algún motivo no desea cachear todos los parámetros de entrada sobrescriba el método get_params_cacheable así:

def get_params_cacheable(self):
    return ['Parameter 1','Parameter 2',... 'Parameter N'] 

Nota: Tenga en cuidado al realizar esta modificación, si no coloca TODOS los parámetros obligatorios para YourComponent al cargar el modelo creado desde su manejador de cache se retornará un error.

Producto desarrollado bajo el curso de posgrado de aprendizaje de máquina avanzado impartido por el profesor Andrés Marino Álvarez – Universidad Nacional
Daniel Espinosa - 2020

Metadata

Release files for keras-grid-search-cacheable 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keras-grid-search-cacheable 1.0.0
File Size Uploaded
keras-grid-search-cacheable-1.0.0.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for keras-grid-search-cacheable 1.0.0
File Interpreter ABI Platform
keras_grid_search_cacheable-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / keras-grid-search-cacheable-1.0.0.tar.gz

Download URL keras-grid-search-cacheable-1.0.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a62e2ad2678c870bdf6234305c92db44e7b35d71cc9c28cb56eeb5daa78d94bb
BLAKE2b-256 checksum
How to use checksums
5f7ead43b35cc8d8bb080b3fe725f642923a745591db6a0ab47c70138870e4f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / keras_grid_search_cacheable-1.0.0-py3-none-any.whl

Download URL keras_grid_search_cacheable-1.0.0-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89d85f59bdac3e910b0b6e8135a76b54773971aa550c6825c01664bd94cd74bd
BLAKE2b-256 checksum
How to use checksums
0c27c95dd753615f6182ca5b4c9f1a39f85cca3e9c6d23d28bab0f3096dea4ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page