semvec/pypi-packages huggingface dataset:
timecache 0.0.4
Time Cache
License: MIT
Keywords: python packaging

==============
 timecache
==============

`timecache` is a timeout-based cache implementation for Python 3.x without
any external dependencies. Depending on the selected backend, the cache can be
made persistent to survive a fresh start of a script (currently, json and
pickle files are supported as backend).

Warning: this is an early alpha version so the interface may change in future
versions.


Setup
-----

Install `timecache` using `pip`:

::

    pip install -U timecache


Example
-------

A cache with a memory backend can be created as follows:

::

    import time
    from timecache import Cache, FIVE_SECONDS

    # create cache with memory backend
    cache = Cache()

    # add a value to the cache with a default duration of 1 minute
    cache["one"] = 1

    # add a value to the cache with a duration of 5 seconds
    cache.set("two", 2, FIVE_SECONDS)

    print("two in cache: {}".format("two" in cache))

    # show cache entry
    print(cache)

    # wait for 6 s
    time.sleep(6)

    # show cache entry
    print(cache)

    print("two in cache: {}".format("two" in cache))


A cache with a json file backend can be created as follows:

::

    import time
    from timecache import Cache, JsonBackend

    # create cache with json backend
    cache = Cache(backend=JsonBackend())

    if not cache.is_existing:
        # add a value to the cache with a default duration of 1 minute
        print("adding new value to the cache...")
        cache["one"] = 1
        print("saving cache to file '{}'".format(cache.filename))
        cache.save()

    # show cache entry
    print(cache)

When calling the script again the cached value will be loaded from the
json file.


Decorators
----------

There are also the three decorators `memorycache`, `jsoncache`,
`picklecache` that allows an easy caching of function return values.


::

    import time
    from timecache import jsoncache, FIVE_SECONDS


    @jsoncache(cache_filename="add.json", ttl=FIVE_SECONDS)
    def add(x, y):
        return x + y


    # new cache entry
    print(add(1, 2))

    # new cache entry
    print(add(1, 3))

    # load existing cache entry
    print(add(1, 2))

    # wait for 6 s
    time.sleep(6)

    # new cache entry, since old entry has expired
    print(add(1, 2))


Debugging
-------

To debug the cache you can simply set the debug level.

::

    import logging
    logging.basicConfig(level=logging.DEBUG)


Testing
-------

For testing additionally install `nose` and then run the tests:

::

    pip install nose
    nosetests


Hint
----

If you do not need a time-based cache, consider the `lru_cache` function of
Python's `functools` module
(https://docs.python.org/3/library/functools.html).
kulc 0.0.9
Keras Utility & Layer Collection.
License: MIT
Requires Python: >=3.6.0


# Keras Utility & Layer Collection [WIP]
Collection of custom layers for Keras which are missing in the main framework. These layers might be useful to reproduce current state-of-the-art deep learning papers using Keras.

## Applications

Using this library the following research papers have been reimplemented in Keras:

- [Attention is all you need](https://github.com/FlashTek/attention-is-all-you-need-keras)
- [Show, attend and tell](https://github.com/FlashTek/show-attend-and-tell-keras)

## Overview of implemented Layers

At the moment the `Keras Layer Collection` offers the following layers/features:

- [Scaled Dot-Product Attention](#sdpattention)
- [Multi-Head Attention](#mhatn)
- [Layer Normalization](#layernorm)
- [Sequencewise Attention](#seqatn)
- [Attention Wrapper](#atnwrapper)

### Scaled Dot-Product Attention <a name="sdpattention"></a>

Implementation as described in [Attention Is All You Need](https://arxiv.org/abs/1706.03762). Performs a non-linear transformation on the values `V` by comparing the queries `Q` with the keys `K`. The illustration below is taken from the paper cited above.

<img src="https://i.imgur.com/7zDGedN.jpg" height=250>

### Multi-Head Attention <a name="mhatn"></a>
Implementation as described in [Attention Is All You Need](https://arxiv.org/abs/1706.03762). This is basically just a bunch a [Scaled Dot-Product Attention](#sdpattention) blocks whose output is combined with a linear transformation. The illustration below is taken from the paper cited above.

<img src="https://i.imgur.com/c0xLAfS.jpg" height=250>

### Layer Normalization <a name="layernorm"></a>


### Sequencewise Attention <a name="seqatn"></a>
This layer applies various attention transformations on data. It needs a time-series of queries and a time-series of values to calculate the attention and the final linear transformation to obtain the output. This is a faster version of the general attention technique. It is similar to the `global attention` method described in [Effective Approaches to Attention-based Neural Machine Translation](https://arxiv.org/abs/1508.04025)

### Attention Wrapper <a name="atnwrapper"></a>
The idea of the implementation is based on the paper [Effective Approaches to Attention-based Neural Machine Translation](https://arxiv.org/abs/1508.04025). This layer can be wrapped around any `RNN` in `Keras`. It calculates for each time step of the `RNN` the attention vector between the previous output and all input steps. This way, a new attention-based input for the `RNN` is constructed. This input is finally fed into the `RNN`. This technique is similar to the `input-feeding` method described in the paper cited. The illustration below is taken from the paper cited above.

<img src="https://i.imgur.com/AZKWSd2.png" height=300>
corsemall 0.2.0
Serves JSON data with CORS allowed from *.json files at given path.
License: MIT

corsemall - serve JSON CORS for local JS dev
============================================

corsemall - CORS 'em all

.. image:: https://travis-ci.org/hvnsweeting/corsemall.svg?branch=master
    :target: https://travis-ci.org/hvnsweeting/corsemall

Installation
------------

By using pip::

    pip install corsemall

Usage
-----

To serve JSON files at path with CORS allowed for all, run::

  corsemall PATH

Features
--------

- Supports both Python2 and Python3
- Run on Linux, OSX, Windows

Authors
-------

Viet Hung Nguyen <hvn@familug.org>