24 KiB
24 KiB
In [1]:
from xception_custom import Xception_wrapper
Using TensorFlow backend. /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)])
In [3]:
import numpy as np from keras.layers import Input
In [8]:
def test_xception_shape(): input_ = np.random.randint(0,256, (240,320,3)) print(input_) inp = Input(input_) xception = Xception_wrapper(include_top=False, weights='imagenet', input_tensor=inp, pooling=None) print('xception:',xception.output.shape) test_xception_shape()
[[[155 225 83] [174 33 86] [ 24 223 10] ... [147 233 79] [232 187 173] [ 69 126 85]] [[166 203 47] [111 65 37] [210 182 244] ... [154 62 70] [ 62 93 101] [132 231 126]] [[ 30 110 125] [242 45 71] [150 10 217] ... [ 38 165 128] [ 64 58 127] [179 174 72]] ... [[159 2 99] [201 220 158] [170 172 13] ... [ 79 72 65] [ 10 228 7] [ 99 60 129]] [[187 249 6] [ 57 166 83] [187 243 66] ... [109 184 147] [142 158 83] [190 61 30]] [[146 238 74] [156 20 43] [ 55 217 43] ... [208 181 141] [196 88 15] [132 225 63]]]
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/eager/execute.py in make_shape(v, arg_name) 145 try: --> 146 shape = tensor_shape.as_shape(v) 147 except TypeError as e: /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in as_shape(shape) 1203 else: -> 1204 return TensorShape(shape) 1205 /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in __init__(self, dims) 773 # Got a list of dimensions --> 774 self._dims = [as_dimension(d) for d in dims_iter] 775 /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in <listcomp>(.0) 773 # Got a list of dimensions --> 774 self._dims = [as_dimension(d) for d in dims_iter] 775 /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in as_dimension(value) 715 else: --> 716 return Dimension(value) 717 /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/framework/tensor_shape.py in __init__(self, value) 184 else: --> 185 self._value = int(value) 186 if (not isinstance(value, compat.bytes_or_text_types) and TypeError: only size-1 arrays can be converted to Python scalars During handling of the above exception, another exception occurred: TypeError Traceback (most recent call last) <ipython-input-8-8f06c869009e> in <module>() 5 xception = Xception_wrapper(include_top=False, weights='imagenet', input_tensor=inp, pooling=None) 6 print('xception:',xception.output.shape) ----> 7 test_xception_shape() <ipython-input-8-8f06c869009e> in test_xception_shape() 2 input_ = np.random.randint(0,256, (240,320,3)) 3 print(input_) ----> 4 inp = Input(input_) 5 xception = Xception_wrapper(include_top=False, weights='imagenet', input_tensor=inp, pooling=None) 6 print('xception:',xception.output.shape) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/keras/engine/input_layer.py in Input(shape, batch_shape, name, dtype, sparse, tensor) 176 name=name, dtype=dtype, 177 sparse=sparse, --> 178 input_tensor=tensor) 179 # Return tensor including _keras_shape and _keras_history. 180 # Note that in this case train_output and test_output are the same pointer. /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs) 89 warnings.warn('Update your `' + object_name + '` call to the ' + 90 'Keras 2 API: ' + signature, stacklevel=2) ---> 91 return func(*args, **kwargs) 92 wrapper._original_function = func 93 return wrapper /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/keras/engine/input_layer.py in __init__(self, input_shape, batch_size, batch_input_shape, dtype, input_tensor, sparse, name) 85 dtype=dtype, 86 sparse=self.sparse, ---> 87 name=self.name) 88 else: 89 self.is_placeholder = False /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py in placeholder(shape, ndim, dtype, sparse, name) 734 dtype = floatx() 735 x = tf_keras_backend.placeholder( --> 736 shape=shape, ndim=ndim, dtype=dtype, sparse=sparse, name=name) 737 if shape is None: 738 if ndim is not None: /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/keras/backend.py in placeholder(shape, ndim, dtype, sparse, name) 996 x = array_ops.sparse_placeholder(dtype, shape=shape, name=name) 997 else: --> 998 x = array_ops.placeholder(dtype, shape=shape, name=name) 999 return x 1000 /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py in placeholder(dtype, shape, name) 2141 "eager execution.") 2142 -> 2143 return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name) 2144 2145 /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py in placeholder(dtype, shape, name) 6258 if shape is None: 6259 shape = None -> 6260 shape = _execute.make_shape(shape, "shape") 6261 _, _, _op = _op_def_lib._apply_op_helper( 6262 "Placeholder", dtype=dtype, shape=shape, name=name) /netpool/homes/wangyo/.conda/envs/tf-cuda9/lib/python3.7/site-packages/tensorflow/python/eager/execute.py in make_shape(v, arg_name) 146 shape = tensor_shape.as_shape(v) 147 except TypeError as e: --> 148 raise TypeError("Error converting %s to a TensorShape: %s." % (arg_name, e)) 149 except ValueError as e: 150 raise ValueError("Error converting %s to a TensorShape: %s." % (arg_name, TypeError: Error converting shape to a TensorShape: only size-1 arrays can be converted to Python scalars.
In [ ]: