Skip to content
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

Shape must be rank 1 but is rank 4 for 'bn1/cond/FusedBatchNorm' #5

Open
vinniyo opened this issue Jun 29, 2018 · 3 comments
Open

Shape must be rank 1 but is rank 4 for 'bn1/cond/FusedBatchNorm' #5

vinniyo opened this issue Jun 29, 2018 · 3 comments

Comments

@vinniyo
Copy link

vinniyo commented Jun 29, 2018

Running windows 10 with everything installed and I get this error:

ValueError: Shape must be rank 1 but is rank 4 for 'bn1/cond/FusedBatchNorm' (op: 'FusedBatchNorm') with input shapes: [?,64,48,48], [1,64,1,1], [1,64,1,1], [1,64,1,1], [1,64,1,1].

Any thoughts?

Full error:
Using TensorFlow backend.
2018-06-29 12:25:03.141799: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-06-29 12:25:03.498122: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1356] Found device 0 with properties:
name: GeForce GTX TITAN Black major: 3 minor: 5 memoryClockRate(GHz): 0.98
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 5.00GiB
2018-06-29 12:25:03.505607: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1435] Adding visible gpu devices: 0
2018-06-29 12:25:03.782568: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-06-29 12:25:03.787601: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:929] 0
2018-06-29 12:25:03.790697: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:942] 0: N
2018-06-29 12:25:03.795210: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4790 MB memory) -> physical GPU (device: 0, name: GeForce GTX TITAN Black, pci bus id: 0000:01:00.0, compute capability: 3.5)
Traceback (most recent call last):
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1567, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 1 but is rank 4 for 'bn1/cond/FusedBatchNorm' (op: 'FusedBatchNorm') with input shapes: [?,64,48,48], [1,64,1,1], [1,64,1,1], [1,64,1,1], [1,64,1,1].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "facenet.py", line 19, in
FRmodel = faceRecoModel(input_shape=(3, 96, 96))
File "C:\Users\vince\Desktop\facenet-face-recognition\inception_blocks_v2.py", line 233, in faceRecoModel
X = BatchNormalization(axis = 1, name = 'bn1')(X)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\base_layer.py", line 460, in call
output = self.call(inputs, **kwargs)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\layers\normalization.py", line 204, in call
training=training)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\backend\tensorflow_backend.py", line 3069, in in_train_phase
x = switch(training, x, alt)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\backend\tensorflow_backend.py", line 3004, in switch
else_expression_fn)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\deprecation.py", line 432, in new_func
return func(*args, **kwargs)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\control_flow_ops.py", line 2072, in cond
orig_res_f, res_f = context_f.BuildCondBranch(false_fn)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\control_flow_ops.py", line 1913, in BuildCondBranch
original_result = fn()
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\layers\normalization.py", line 165, in normalize_inference
epsilon=self.epsilon)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\backend\tensorflow_backend.py", line 1894, in batch_normalization
is_training=False
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\nn_impl.py", line 904, in fused_batch_norm
name=name)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 3774, in _fused_batch_norm
is_training=is_training, name=name)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 3392, in create_op
op_def=op_def)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1734, in init
control_input_ops)
File "C:\Users\vince\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1570, in _create_c_op
raise ValueError(str(e))
ValueError: Shape must be rank 1 but is rank 4 for 'bn1/cond/FusedBatchNorm' (op: 'FusedBatchNorm') with input shapes: [?,64,48,48], [1,64,1,1], [1,64,1,1], [1,64,1,1], [1,64,1,1].

@KeshavAdityaRP
Copy link

Even I am having the same issue

@bhattrajat
Copy link

bhattrajat commented Jul 17, 2018

I have the same problem after I upgraded my Keras version from 2.1.6 to 2.2.0. I am not sure what part of code caused this error in 2.2.0. You can install keras 2.1.6 by using pip install keras==2.1.6 I Hope this solves the issue temporarily.

@ode233
Copy link

ode233 commented Aug 2, 2018

I'm try to updata Keras from 2.2.0 to 2.2.2 ,it's also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants