Skip to content

ValueError: Dimension size must be evenly divisible by 2 but is 1 #86

@mikechen66

Description

@mikechen66

While I test the scrip of fintune.py on TensorFlow 1.5, the system throws the errorn as follows. I list the information inlucuding ValueError, possible questionable code and traceback as follows. Appreciate your help in advance.

1. General Message

ValueError: Dimension size must be evenly divisible by 2 but is 1
Number of ways to split should evenly divide the split dimension for 'split_1' (op: 'Split') with input shapes: [], [5,5,2,1] and with computed input

2. Code

It targets to the line of code as follows.

alexnet.py

weight_groups = tf.split(value=weights, num_or_size_splits=group, axis=3) 

3. Detailed Error Message:

$ python finetune.py --conv=4 --dropout_rate=0.03

Traceback (most recent call last):
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1607, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension size must be evenly divisible by 2 but is 1
Number of ways to split should evenly divide the split dimension for 'split_1' (op: 'Split') with input shapes: [], [5,5,2,1] and with computed input tensors: input[0] = <3>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "finetune.py", line 97, in
model = AlexNet(x, keep_prob, num_classes, train_layers)
File "/home/nano/Documents/finetune_alexnet_with_tf/alexnet.py", line 56, in init
self.create()
File "/home/nano/Documents/finetune_alexnet_with_tf/alexnet.py", line 69, in create
conv2 = conv(pool1, 5, 5, 256, 1, 1, name='conv2', group=2)
File "/home/nano/Documents/finetune_alexnet_with_tf/alexnet.py", line 159, in conv
weight_groups = tf.split(value=weights, num_or_size_splits=group, axis=3)
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/ops/array_ops.py", line 1684, in split
axis=axis, num_split=num_or_size_splits, value=value, name=name)
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/ops/gen_array_ops.py", line 9898, in split
"Split", split_dim=axis, value=value, num_split=num_split, name=name)
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/framework/op_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 3357, in create_op
attrs, op_def, compute_device)
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 3426, in _create_op_internal
op_def=op_def)
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1770, in init
control_input_ops)
File "/home/nano/.virtualenvs/win/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1610, in _create_c_op
raise ValueError(str(e))
ValueError: Dimension size must be evenly divisible by 2 but is 1
Number of ways to split should evenly divide the split dimension for 'split_1' (op: 'Split') with input shapes: [], [5,5,2,1] and with computed input

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions