Closed Duchstf closed 4 years ago
We are enhancing the quantizers to accept just the name, like in Keras. Meanwhile, try to do "stochastic_ternary()" and "ternary()".
Best regards,
Claudionor
On Mon, Feb 3, 2020 at 9:32 AM Duc Hoang notifications@github.com wrote:
Hi,
I was trying to use the QConv1D layer and encounter this error. Does anyone have any idea why?
Traceback (most recent call last): File "quantize-Conv1D.py", line 179, in
UseNetwork(args.weight_file, save_model = args.save_model, load_weights=lw) File "quantize-Conv1D.py", line 142, in UseNetwork model = QConv1D_model(weights_f, load_weights) File "quantize-Conv1D.py", line 101, in QConv1D_model x = QConv1D(filters=128, kernel_size=3, kernel_quantizer="stochastic_ternary", bias_quantizer="ternary", name="conv1d_1")(x) File "/home/duchstf/miniconda3/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 842, in call outputs = call_fn(cast_inputs, *args, **kwargs) File "/home/duchstf/miniconda3/lib/python3.7/site-packages/tensorflow_core/python/autograph/impl/api.py", line 237, in wrapper raise e.ag_error_metadata.to_exception(e) AttributeError: in converted code: relative to /home/duchstf/miniconda3/lib/python3.7/site-packages: qkeras/qconvolutional.py:127 call * outputs = tf.keras.backend.conv1d( tensorflow_core/python/keras/backend.py:4804 conv1d kernel_shape = kernel.shape.as_list() AttributeError: 'stochastic_ternary' object has no attribute 'shape'
This is how the QConv1D layer was used in my code
x = x_in = Input(IN_SHAPE, name="input") x = QConv1D(filters=128, kernel_size=3, kernel_quantizer="stochastic_ternary", bias_quantizer="ternary", name="conv1d_1")(x)
Thanks,
Duc.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/qkeras/issues/13?email_source=notifications&email_token=AM5ENPH2DKRTGTURDOJR56LRBBIKPA5CNFSM4KPJDQLKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IKVEWKQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5ENPGW54A57AIBJIINNHDRBBIKPANCNFSM4KPJDQLA .
Thank you so much! It works now!
There is still a minor problem regarding print_qstats
. However, everything works fine if I comment it out.
Traceback (most recent call last):
File "quantize-Conv1D.py", line 179, in <module>
UseNetwork(args.weight_file, save_model = args.save_model, load_weights=lw)
File "quantize-Conv1D.py", line 142, in UseNetwork
model = QConv1D_model(weights_f, load_weights)
File "quantize-Conv1D.py", line 131, in QConv1D_model
print_qstats(model)
File "/home/duchstf/miniconda3/lib/python3.7/site-packages/qkeras/estimate.py", line 493, in print_qstats
model_ops = extract_model_operations(model)
File "/home/duchstf/miniconda3/lib/python3.7/site-packages/qkeras/estimate.py", line 415, in extract_model_operations
kernel_h, kernel_w, _, _ = weight.shape
ValueError: not enough values to unpack (expected 4, got 3)
Thanks,
Duc.
Created PR to fix the problem. Thanks!
Hi,
I was trying to use the
QConv1D
layer and encounter this error. Does anyone have any idea why?This is how the
QConv1D
layer was used in my codeThanks,
Duc.