fversaci / wavetf Goto Github PK
View Code? Open in Web Editor NEWWaveTF: a 1D and 2D wavelet library for TensorFlow and Keras
License: Apache License 2.0
WaveTF: a 1D and 2D wavelet library for TensorFlow and Keras
License: Apache License 2.0
hey! Excellent project but I cannot design my model using inverse wavelet transform. I get this error that says : [[node model_4/inv_haar_wave_layer1d_6/Reshape (defined at kaggle/working/WaveTF/wavetf/_haar_mm.py:96) ]] [Op:__inference_train_function_19480]
Errors may have originated from an input operation.
Input Source operations connected to node model_4/inv_haar_wave_layer1d_6/Reshape:
model_4/dropout_31/dropout/Mul_1 (defined at tmp/ipykernel_28/4029629701.py:5)
Function call stack:
train_function
Can you show me a basic model example that you used inverse wavelet transform that would be really helpful!
TypeError: Exception encountered when calling layer "haar_wave_layer2d_5" (type HaarWaveLayer2D).
in user code:
File "/usr/local/lib/python3.7/dist-packages/wavetf/_base_wavelets.py", line 107, in call *
self.nx, self.ny = map(lambda x: math.ceil(x / 2), [self.ox, self.oy])
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
Call arguments received:
• batch=tf.Tensor(shape=(None, None, None, 64), dtype=float32)
I've been trying to use the DWT and IDWT layer inside a residual module:
def wavelet_residual_block(block_input, num_filters, momentum=0.8, wave_kern='db2'):
x = WaveTFFactory().build(wave_kern, dim = 2)(block_input) ##
x = BatchNormalization()(x) ##
x = Conv2D(num_filters, kernel_size=3, padding='same')(x)
x = BatchNormalization(momentum=momentum)(x)
x = PReLU(shared_axes=[1, 2])(x)
x = Conv2D(num_filters, kernel_size=3, padding='same')(x)
x = BatchNormalization(momentum=momentum)(x)
x = WaveTFFactory().build(wave_kern, dim = 2, inverse = True)(x)
x = Add()([block_input, x])
return x
The model was used on an image dataset.
tensorflow-gpu ==2.3
keras == 2.3
wave_kern = 'db2'
inputs = Input(shape)
# x = wave(inputs)
wave0 = inputs
print(K.int_shape(inputs))
wave1 = WaveTFFactory.build(wave_kern,dim=2)(wave0)
inputs is (None, 512, 512, 1)
error is Invalid value in tensor used for shape: -512
why did this mistake happen
To avoid runtime error with tf.reshape
Error: Only one input size may be -1, not both 0 and 2
Please consider a small code change in:
_daubachies_conv.py line 216
# s1 = tf.reshape(s1, [self.bs, self.cn*self.ox, -1, 1]) # >>> delete
ny_dim = s1.shape[3] # <<< insert
s1 = tf.reshape(s1, [self.bs, self.cn*self.ox, ny_dim, 1]) # <<< insert
Hi friend,
I ran the code of mini ccn, but python returns:
`ValueError: Exception encountered when calling layer "daub_wave_layer2d" (type DaubWaveLayer2D).
in user code:
File "C:\Users\marco\AppData\Local\Programs\Python\Python39\lib\site-packages\wavetf\_base_wavelets.py", line 109, in call *
return self.kernel_function(batch)
File "C:\Users\marco\AppData\Local\Programs\Python\Python39\lib\site-packages\wavetf\_daubachies_conv.py", line 216, in kernel_function *
s1 = tf.reshape(s1, [self.bs*self.cn*self.ox, -1, 1])
ValueError: Invalid value in tensor used for shape: -672
Call arguments received:
• batch=tf.Tensor(shape=(None, 224, 224, 3), dtype=float32)`
The images are RGB:
img_size= 224
channels = 3
input_shape = (img_size, img_size, channels)
Hi,
Do you think about implementing new wavelets such as db10, db15, ... ?
Or is there a way to implement them based on your code?
I tried to do it on my own for db15 (only direct transform) but I got some shape issues. I believe it is due to the daub_cols1
method and the padding which I am not sure to understand well. Do you have some insights for this?
Moreover, how will you handle the case when the input size is not a multiple of 20 or 30?
Thanks
I try to use "tf.keras.models.load_model",error happen
raise ValueError('Unknown ' + printable_module_name + ': ' + class_name)
ValueError: Unknown layer: HaarWaveLayer2D
but I can't be used directly ,like this(It,s also wrong to do so)
from wavetf._haar_conv import *
...
_custom_objects = {
"HaarWaveLayer2D" : HaarWaveLayer2D,
}
model = tf.keras.models.load_model("path/to/your/model", custom_objects=_custom_objects)
How can I solve this problem
Hi,
Is there any way to implement a new wavelet with designed coefficients? I designed a new wavelet for my school project and I want to implement this wavelet using Wavetf.
Thank you!
Hi,
Thanks for the great package! I tried running the example on the README page (transform and anti-transform) in TensorFlow 2.2.0, and I get the following error:
Traceback (most recent call last):
File "/home/ralager/ml4convection/ml4convection/stuff.py", line 772, in
t1 = w.call(t0)
File "/home/ralager/anaconda3/lib/python3.7/site-packages/WaveTF-0.1-py3.7.egg/wavetf/_base_wavelets.py", line 109, in call
File "/home/ralager/anaconda3/lib/python3.7/site-packages/WaveTF-0.1-py3.7.egg/wavetf/_haar_conv.py", line 169, in kernel_function
File "/home/ralager/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/nn_ops.py", line 1729, in conv1d_v2
dilations=dilations)
File "/home/ralager/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 574, in new_func
return func(*args, **kwargs)
File "/home/ralager/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 574, in new_func
return func(*args, **kwargs)
File "/home/ralager/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/nn_ops.py", line 1663, in conv1d
name=name)
File "/home/ralager/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 937, in conv2d
_ops.raise_from_not_ok_status(e, name)
File "/home/ralager/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 6653, in raise_from_not_ok_status
six.raise_from(core._status_to_exception(e.code, message), None)
File "", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: input must be 4-dimensional[32,1,900,200,1] [Op:Conv2D]
It seems like an extra dimension is being added to the tensor somewhere. Do you have a solution for this?
Thanks,
Ryan
I would like to use the 2D Haar transform so that if the forward transformation introduced padding, the inverse transformation would then remove that padding, obtaining the initial input.
Happy to contribute if needed.
pip install 没有wavetf这个包
Line 167 in 6e3f2b0
ValueError: Shape must be rank 4 but is rank 5 for 'conv1d' (op: 'Conv2D') with input shapes: [1,1,768,256,1], [1,2,1,1].
With my code:
tf.reset_default_graph()
img = tf.placeholder(tf.float32, shape=(1, 256, 256, 3))
features = HaarWaveLayer2D().call(img)
Any ideas why?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.