'(What does the error mean?) Number of ways to split should evenly divide the split dimension, but got split_dim 1 (size = 1) and num_split 4
Recently, I have tried running a Github code but I obtained the following error:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Number of ways to split should evenly divide the split dimension, but got split_dim 1 (size = 1) and num_split 4 [[node model_5/model_4/up_sampling3d/split (defined at /home/svu/e0310071/self-supervised-3d-tasks/self_supervised_3d_tasks/finetune.py:174) ]] [Op:__inference_distributed_function_11489]
Does anyone know what does the error mean? What does split_dim and num_split means?
Solution 1:[1]
There is no provided target steps but verification could determine with the message return from the method, upsamplig or down sampling they are specific with current and target shape. ( Calculation create by eventually input if you read from the website where one node of input can provide multiple of the output to the target nodes in the next layer )
It without step we provide target or basics method you may reference but the question is widely of the scopes, the calculation can be multi-target nodes or single where it is common methods.
Observed there is the upsampling and slices methods where they not allowcated target sequences.
up_sampling3d is not return the error since 2D is often use and 3D is for target use. ( The reason we testing and the cat use my arms as pillows and environment )
ValueError: Input 0 of layer "up_sampling2d" is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: (None, 180, 1)
Sample ( 1 ):
split0, split1, split2 = tfds.even_splits('train', n=3)
ds = tfds.load('movielens/100k-ratings', split=split0)
# <PrefetchDataset element_spec={'bucketized_user_age': TensorSpec(shape=(), dtype=tf.float32, name=None), 'movie_genres': TensorSpec(shape=(None,), dtype=tf.int64, name=None),
# 'movie_id': TensorSpec(shape=(), dtype=tf.string, name=None), 'movie_title': TensorSpec(shape=(), dtype=tf.string, name=None), 'raw_user_age': TensorSpec(shape=(), dtype=tf.float32, name=None),
# 'timestamp': TensorSpec(shape=(), dtype=tf.int64, name=None), 'user_gender': TensorSpec(shape=(), dtype=tf.bool, name=None), 'user_id': TensorSpec(shape=(), dtype=tf.string, name=None),
# 'user_occupation_label': TensorSpec(shape=(), dtype=tf.int64, name=None), 'user_occupation_text': TensorSpec(shape=(), dtype=tf.string, name=None), 'user_rating': TensorSpec(shape=(), dtype=tf.float32, name=None),
# 'user_zip_code': TensorSpec(shape=(), dtype=tf.string, name=None)}>
Sample ( 2 ):
builder = tfds.builder('cats_vs_dogs', data_dir='file:\\\\F:\\datasets\\downloads\\PetImages\\')
ds = builder.as_dataset(builder)
ds = tfds.load('cats_vs_dogs', split='train', shuffle_files=True)
assert isinstance(ds, tf.data.Dataset)
print(ds)
Sample ( 3 ):
DATA = [ 0 ] ### It should be matching of data and labels
dataset = tf.data.Dataset.from_tensor_slices((tf.constant(DATA, dtype=tf.float32),tf.constant(np.reshape(action, (1, 1, 1, 1)))))
I had another case when there is not matching memory or denses they are unexpecting... ( reshape for 3D )
Success: [0.]]]] 1/1 [==============================] - 3s 3s/step - loss: 0.0000e+00 - accuracy: 1.0000
Failure if x_shape[axis] is not None: IndexError: Exception encountered when calling layer "up_sampling3d_1" (type UpSampling3D).
My implementation in a Pixel helicopter game, tricks when we perfomring on screen it has large data need to significant but when we perform on data information only it also indicated significants.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
: Model
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
model = tf.keras.models.Sequential([
tf.keras.layers.InputLayer(input_shape=(180, 1)),
tf.keras.layers.Reshape((3, 2, 30, 1)),
tf.keras.layers.UpSampling3D(size=4),
tf.keras.layers.Dense(1024),
])
( a bit funny conversation, How you have know that 2D is often use than 3D? His funny question in classroom but where is the Dodo icon !? )
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Martijn Pieters |