I'm currently reproducing this code
In the transform_rnn file, I have an issue.
class augmentaion(Layer):
def __init__(self,**kwargs):
self.supports_masking = True
self.uses_learning_phase = True
super(augmentaion, self).__init__(**kwargs)
def compute_mask(self, input, mask):
return mask
def call(self,x,training=None):
deta1 = 0.3
deta2 = 0.3
deta3 = 0.3
seed = np.random.randint(1, 10e6)
rng = RandomStreams(seed=seed)
theta1 = rng.uniform(size=(x.shape[0],1),low=-deta1,high=deta1,dtype='float32')
theta2 = rng.uniform(size=(x.shape[0],1),low=-deta2,high=deta2,dtype='float32')
theta3 = rng.uniform(size=(x.shape[0],1),low=-deta3,high=deta3,dtype='float32')
theta = K.concatenate([theta1,theta2,theta3],axis=-1)
theta = K.tile(theta,x.shape[1])
theta = theta.reshape((x.shape[0], x.shape[1], 3))
theta = theta.reshape((theta.shape[0]*theta.shape[1], theta.shape[2]))
M = _fusion(theta)
output = _transform_rot(M, x)
return K.in_train_phase(output,x,training = training)
I have this error
AttributeError: in user code:
B:\Stage\skeleton2\transform_rnn.py:171 call * theta = K.concatenate([theta1,theta2,theta3],axis=-1) C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\tensorflow\python\util\dispatch.py:206 wrapper ** return target(*args, **kwargs) C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\tensorflow\python\keras\backend.py:3087 concatenate rank = ndim(tensors[0]) C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\tensorflow\python\keras\backend.py:1482 ndim return x.shape.rank
AttributeError: 'TensorVariable' object has no attribute 'rank'
Here are my imports
import theano.tensor as T
import numpy as np
import theano
from tensorflow.keras import backend as K
from keras.engine.topology import Layer
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
floatX = theano.config.floatX
I can't find any solutions (I also have a problem with x.shape[0] which is 'NONE', but I don't think these errors are linked)
Thanks!
Edit : If I use just keras instead of tensoflow.keras, I have this error
Traceback (most recent call last):
File "B:\Stage\skeleton2\va-rnn.py", line 38, in <module>
from keras import initializers
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\utils\__init__.py", line 26, in <module>
from .multi_gpu_utils import multi_gpu_model
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\utils\multi_gpu_utils.py", line 7, in <module>
from ..layers.merge import concatenate
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\layers\__init__.py", line 4, in <module>
from ..engine.base_layer import Layer
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\engine\__init__.py", line 3, in <module>
from .input_layer import Input
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\engine\input_layer.py", line 7, in <module>
from .base_layer import Layer
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\engine\base_layer.py", line 12, in <module>
from .. import initializers
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\initializers\__init__.py", line 124, in <module>
populate_deserializable_objects()
File "C:\Users\Users\anaconda3\envs\myenv\lib\site-packages\keras\initializers\__init__.py", line 82, in populate_deserializable_objects
generic_utils.populate_dict_with_module_objects(
AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
I've tested keras 2.4 and 2.2