def ndim(x):
    dims = x.get_shape()._dims
    if dims is not None:
        return len(dims)
    return None
Returns the number of axes in a tensor, as an integer.
dataset/ETHPy150Open fchollet/keras/keras/backend/tensorflow_backend.py/ndim