def empty_like(prototype, dtype=None, order='K', subok=True, shape=None): ''' empty_like(prototype, dtype=None, order='K', subok=True, shape=None) Return a new var with the same shape and type as a given var. Parameters ---------- prototype : var_like The shape and data-type of prototype define these same attributes of the returned array. dtype : data-type, optional Overrides the data type of the result. order : {'C', 'F', 'A', or 'K'}, optional Compatible with numpy. subok : bool, optional. Compatible with numpy. shape : int or sequence of ints, optional. Overrides the shape of the result. Returns ------- out : var Var of uninitialized (arbitrary) data with the same shape and type as prototype. Example: ------- >>> a = ([1,2,3], [4,5,6]) >>> np.empty_like(a) ''' __order_assert(order) dst_dtype, dst_shape = __array_like_type(prototype, dtype, order, shape) return _F.placeholder(dst_shape, prototype.data_format, dst_dtype)
def empty(shape, dtype=float32, order='C'): ''' empty(shape, dtype=float32) Return a new var of given shape and type, without initializing entries. Parameters ---------- shape : int or tuple of int Shape of the empty var, e.g., (2, 3) or 2. dtype : data-type, optional Desired output data-type for the array, e.g, np.int8. Default is np.float32. order : {'C', 'F', 'A', or 'K'}, optional Compatible with numpy. Returns ------- out : var Var of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. Example: ------- >>> np.empty([2, 2]) ''' __order_assert(order) return _F.placeholder(shape, _F.NCHW, dtype)
def empty_like(prototype, dtype=None, order='K', subok=True, shape=None): __order_assert(order) dst_dtype, dst_shape = __array_like_type(prototype, dtype, order, shape) return _F.placeholder(dst_shape, prototype.data_format, dst_dtype)
def empty(shape, dtype=float32, order='C'): __order_assert(order) return _F.placeholder(shape, _F.NCHW, dtype)
def int(value): res = F.placeholder([], F.NCHW, F.int) res.write([value]) res.fix(F.Const) return res