Skip to content

Commit 4ab2576

Browse files
authored
Merge pull request #7 from eliorc/dev
Version update 0.4.1
2 parents 4c0fbf9 + c31531b commit 4ab2576

10 files changed

Lines changed: 32 additions & 11 deletions

File tree

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ jobs:
2828
steps:
2929
# Checkout repository
3030
- checkout
31-
# Install dependencies, uses cache if not update
31+
# Install dependencies, uses cache if not updat
3232
- restore_cache:
3333
key: test-deps-{{ .Branch }}-{{ checksum "requirements/test.txt" }}
3434
- run:
3535
name: install tests dependencies
3636
command: |
3737
python3 -m venv venv
3838
source venv/bin/activate
39+
pip install -U pip
3940
pip install -r requirements/test.txt
4041
pip install -U pip setuptools
4142
- save_cache:

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
.. image:: https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7-blue.svg
1010
:alt: Supported Python versions
1111

12-
.. image:: https://img.shields.io/badge/tensorflow-2.0.0--beta1-orange.svg
12+
.. image:: https://img.shields.io/badge/tensorflow-2.0.0--rc0-orange.svg
1313
:alt: Supported TensorFlow versions
1414

1515
.. image:: https://codecov.io/gh/eliorc/tavolo/branch/master/graph/badge.svg
@@ -28,7 +28,7 @@ Tavolo
2828
| tavolo gathers implementations of these useful ideas from the community (by contribution, from `Kaggle`_ etc.)
2929
and makes them accessible in a single PyPI hosted package that compliments the `tf.keras`_ module.
3030
|
31-
| *Notice: tavolo is developed for TensorFlow 2.0 (right now on beta), most modules will work with earlier versions but some won't (like LayerNormalization)*
31+
| *Notice: tavolo is developed for TensorFlow 2.0 (right now on pre-release), most modules will work with earlier versions but some won't (like LayerNormalization)*
3232
3333
Documentation
3434
-------------

docs/source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Welcome to tavolo's documentation!
1111
1212
.. warning::
1313

14-
tavolo is developed for TensorFlow 2.0 (right now on beta), most modules will work with earlier versions but some won't (like LayerNormalization)
14+
tavolo is developed for TensorFlow 2.0 (right now on pre-release), most modules will work with earlier versions but some won't (like LayerNormalization)
1515

1616
Showcase
1717
--------

docs/source/install.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
Installation
22
============
33

4-
| tavolo is hosted on PyPI, and the source code is available on Github
4+
| tavolo is hosted on PyPI, and the source code is available on Github.
5+
6+
.. note::
7+
8+
Tavolo will not install tensorflow by itself, this is to prevent installations of CPU and GPU versions together.
9+
It is the user's responsibility to install the tensorflow library
510

611
Install from PyPI
712
+++++++++++++++++

requirements/docs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ sphinxcontrib-httpdomain
44
sphinx_rtd_theme
55
pygments
66
pygments-style-github
7+
tensorflow==2.0.0-rc0
78
tavolo

requirements/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pytest
22
pytest-cov
33
twine
44
codecov
5+
tensorflow==2.0.0-rc0

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup
22

3-
VERSION = '0.4.0'
3+
VERSION = '0.4.1'
44

55
setup(name='tavolo',
66
version=VERSION,
@@ -10,6 +10,5 @@
1010
classifiers=['License :: OSI Approved :: MIT License'],
1111
packages=['tavolo'],
1212
install_requires=[
13-
'numpy',
14-
'tensorflow==2.0.0-beta1'],
13+
'numpy'],
1514
python_requires='>=3.5')

tavolo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__name__ = 'tavolo'
2-
__version__ = '0.4.0'
2+
__version__ = '0.4.1'
33

44
from . import embeddings
55
from . import normalization

tavolo/seq2seq.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ def __init__(self,
9696
self.Q = None
9797
self.K = None
9898
self.V = None
99+
self.output_projection = None
99100
self.dropout = tf.keras.layers.Dropout(rate=dropout_rate)
100101
self.very_small_value = (-2 ** 32 + 1) # Used for padding to avoid attending
101102

102103
def build(self, input_shape):
103104
# Units
104-
self.n_units = self.n_units or input_shape[-1]
105+
channels = input_shape[-1]
106+
self.n_units = self.n_units or channels
105107

106108
# Test units - n_heads validity
107109
if self.n_units % self.n_heads != 0:
@@ -110,19 +112,28 @@ def build(self, input_shape):
110112
# Linear projections
111113
self.Q = tf.keras.layers.Dense(units=self.n_units,
112114
activation=None,
115+
use_bias=False,
113116
name='Q',
114117
dtype=self.dtype)
115118

116119
self.K = tf.keras.layers.Dense(units=self.n_units,
117120
activation=None,
121+
use_bias=False,
118122
name='K',
119123
dtype=self.dtype)
120124

121125
self.V = tf.keras.layers.Dense(units=self.n_units,
122126
activation=None,
127+
use_bias=False,
123128
name='V',
124129
dtype=self.dtype)
125130

131+
self.output_projection = tf.keras.layers.Dense(units=channels,
132+
activation=None,
133+
use_bias=False,
134+
name='output_projection',
135+
dtype=self.dtype)
136+
126137
super().build(input_shape)
127138

128139
def compute_mask(self, inputs, mask=None):
@@ -210,6 +221,9 @@ def call(self, inputs,
210221
outputs = tf.concat(tf.split(outputs, self.n_heads, axis=0),
211222
axis=2) # shape=(batch_size, time_steps, n_units)
212223

224+
# Project output
225+
outputs = self.output_projection(outputs) # shape=(batch_size, time_steps, channels)
226+
213227
return outputs
214228

215229
def get_config(self):

tests/seq2seq/multi_headed_self_attention_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_shapes():
2323

2424
# Assert correctness of output shapes
2525
assert output_single.shape == input_shape_3d
26-
assert output_mh.shape == input_shape_3d[:-1] + (n_units_mh,)
26+
assert output_mh.shape == input_shape_3d
2727

2828

2929
def test_masking():

0 commit comments

Comments
 (0)