FCRN-DepthPrediction icon indicating copy to clipboard operation
FCRN-DepthPrediction copied to clipboard

About the get_incoming_shape function in network.py

Open yaodaoboy opened this issue 7 months ago • 0 comments

In network.py, the author use the code as followed to judge whether the incoming variable is a np.array, list, or tuple object

def get_incoming_shape(incoming):
   """ Returns the incoming data shape """
   if isinstance(incoming, tf.Tensor):
       return incoming.get_shape().as_list()
   elif type(incoming) in [np.array, list, tuple]:
       return np.shape(incoming)
   else:
       raise Exception("Invalid incoming layer.")

However, np.array is a function to change a array-like object to a np.ndarray object. np.ndarray is the type name instead of np.array.

So, the correct code may be like as followed:

def get_incoming_shape(incoming):
    """ Returns the incoming data shape """
    if isinstance(incoming, tf.Tensor):
        return incoming.get_shape().as_list()
    elif type(incoming) in [np.ndarray, list, tuple]:
    # elif isinstance(incoming, (np.ndarray, list, tuple)):
        return np.shape(incoming)
    else:
        raise Exception("Invalid incoming layer.")

yaodaoboy avatar May 10 '25 12:05 yaodaoboy