MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / concatenate

Function concatenate

tensorflow/python/keras/backend.py:2563–2594  ·  view source on GitHub ↗

Concatenates a list of tensors alongside the specified axis. Arguments: tensors: list of tensors to concatenate. axis: concatenation axis. Returns: A tensor. Example: ```python >>> a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> b = tf.constant([[1

(tensors, axis=-1)

Source from the content-addressed store, hash-verified

2561
2562@keras_export('keras.backend.concatenate')
2563def concatenate(tensors, axis=-1):
2564 """Concatenates a list of tensors alongside the specified axis.
2565
2566 Arguments:
2567 tensors: list of tensors to concatenate.
2568 axis: concatenation axis.
2569
2570 Returns:
2571 A tensor.
2572
2573 Example:
2574 ```python
2575 >>> a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
2576 >>> b = tf.constant([[10, 20, 30], [40, 50, 60], [70, 80, 90]])
2577 >>> tf.keras.backend.concatenate((a, b), axis=-1)
2578 <tf.Tensor: id=14, shape=(3, 6), dtype=int32, numpy=
2579 array([[ 1, 2, 3, 10, 20, 30],
2580 [ 4, 5, 6, 40, 50, 60],
2581 [ 7, 8, 9, 70, 80, 90]], dtype=int32)>
2582 ```
2583 """
2584 if axis < 0:
2585 rank = ndim(tensors[0])
2586 if rank:
2587 axis %= rank
2588 else:
2589 axis = 0
2590
2591 if py_all(is_sparse(x) for x in tensors):
2592 return sparse_ops.sparse_concat(axis, tensors)
2593 else:
2594 return array_ops.concat([to_dense(x) for x in tensors], axis)
2595
2596
2597@keras_export('keras.backend.reshape')

Callers 3

repeat_elementsFunction · 0.70
local_convFunction · 0.70

Calls 4

ndimFunction · 0.85
to_denseFunction · 0.85
is_sparseFunction · 0.70
concatMethod · 0.45

Tested by

no test coverage detected