-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't run haste layers in Keras #33
Comments
did you get / solve this issue ? |
Unfortunatelly not yet. I tried to run a sequential model with it, but for that it has to be an instance of class Layer. |
Regarding the first error
In the Keras API docs I found this:
The last line in which the error message is thrown is the ..keras/layers/core.py:1359, which is wrapped backprop.GradientTape.
Does that mean that the haste layers can't be used with an keras Input layer? If so, how can I create a model with them if neither the sequential nor the functional api (requires the input layer AFAIK) can be used? In your example on the main page the layer gets a tensor directly. Do I have to handle batches manually and input the data directly instead of letting the fit function work? |
import numpy as np train_x = np.random.rand(500,40,20) inputs = tf.keras.Input(shape=(train_x.shape[1], train_x.shape[2])) x, state = haste1(inputs, training=True) model = tf.keras.Model(inputs=inputs, outputs=outputs) print(model.summary()) opt = tf.keras.optimizers.Adam(learning_rate=0.01) model_hist = model.fit(train_x, train_y, epochs=10, batch_size=32, verbose=1) this code is working for me |
For me the error still remains. What python/Tensorflow version did you use for testing? |
it's a jupyter notebook on a Docker image:
GPU: "NVIDIA-SMI 418.116.00 Driver Version: 418.116.00 CUDA Version: 10.2"
print(tf.__version__)
2.3.0
from platform import python_version
print(python_version())
3.7.10
haste.__version__
print(haste.__version__)
0.5.0-rc0
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
![image](https://user-images.githubusercontent.com/1186658/123145290-f6586500-d45c-11eb-85e2-62faf26a78f7.png)
I have also a version tf 2.4 / py 3.8 but not tested on this image
|
Does it works for you ? |
No. |
I tested it in a google colab (https://colab.research.google.com/drive/1mHuT35cnW5uOgulDjHGPf88gm74O9Caz?usp=sharing) and there the same error occurs. |
hello, everyone. actually, the 'real' bug here is this - 'TypeError: haste_lstm() missing 1 required positional argument: 'training' it happens because keras 'wraps' this call in Line 211 in 459608c
into TFOpLambda LIB.haste_lstm expects 'training' argument, but when this call is wrapped, this argument is lost because in constructor of TFOpLambda the flag '_expects_training_arg' explicitly set to False this is what happens in tf 2.5.0 p.s. obvious immediate fix - just comment this line in keras sources |
Hey, thank you for figuring that out, I'll try that! But is there hope to get that fixed officially, without changing the keras core file? |
@thegodone actually, can you add this code as an example of how to mix haste layers into tf.keras model, I think new user will appreciate it. |
Hello,
I know this seems more of a debugging problem/problem on my side, but get the following error message when running my code, and it only appears when running it with a haste layer:
I construct the model with the following code:
train_x numpy array shape is (21788, 1000, 4)
OS: Ubuntu 20.04
Python version: 3.7
Keras: 2.4.3
Tensorflow: 2.4.1
numpy: 1.19.5
GPU: GTX 1060
CUDA: 11.2
Normally I wouldn't post those error messages on github, but as the code would run without the haste layer, I suspect that the cause of the error lies somewhere close to it, and this repo seems to be the best place to ask and I didn't find any solutions elsewhere. I hope you can help me, I'd really like to try out your implementation for my dataset.
The text was updated successfully, but these errors were encountered: