Пример #1
0
def standardize_X(shape, X):
	if not numpy_array(X):
		X = np.asarray(X)

	if len(shape) == 4 and len(X.shape) == 2:
		return X.reshape(-1, shape[2], shape[3], shape[1]).transpose(0, 3, 1, 2)
	else:
		return X
Пример #2
0
def standardize_X(shape, X):
	if not numpy_array(X):
		X = np.asarray(X)

	if len(shape) == 4 and len(X.shape) == 2:
		return X.reshape(-1, shape[2], shape[3], shape[1]).transpose(0, 3, 1, 2)
	else:
		return X
Пример #3
0
def standardize_Y(shape, Y):
    if not numpy_array(Y):
        Y = np.asarray(Y)
    if len(Y.shape) == 1:
        Y = Y.reshape(-1, 1)
    if len(Y.shape) == 2 and len(shape) == 2:
        if shape[-1] != Y.shape[-1]:
            return one_hot(Y, n=shape[-1])
        else:
            return Y
    else:
        return Y
Пример #4
0
def standardize_Y(shape, Y):
	if not numpy_array(Y):
		Y = np.asarray(Y)
	if len(Y.shape) == 1:
		Y = Y.reshape(-1, 1)
	if len(Y.shape) == 2 and len(shape) == 2:
		if shape[-1] != Y.shape[-1]:
			return one_hot(Y, n=shape[-1])
		else:
			return Y
	else:
		return Y
Пример #5
0
def ZeroOneScale(X):
    if not numpy_array(X):
        X = np.asarray(X)
    return X / 255.
Пример #6
0
def Standardize(X):
    if not numpy_array(X):
        X = np.asarray(X)
    return X / 127.5 - 1.
Пример #7
0
def ImgToConv(X):
    if not numpy_array(X):
        X = np.asarray(X)
    return X.transpose(0, 3, 1, 2)
Пример #8
0
def FlatToImg(X, w, h, c):
    if not numpy_array(X):
        X = np.asarray(X)
    return X.reshape(-1, w, h, c)
Пример #9
0
def ZeroOneScale(X):
    if not numpy_array(X):
        X = np.asarray(X)
    return X / 255.
Пример #10
0
def Standardize(X):
    if not numpy_array(X):
        X = np.asarray(X)
    return X / 127.5 - 1.
Пример #11
0
def ImgToConv(X):
    if not numpy_array(X):
        X = np.asarray(X)
    return X.transpose(0, 3, 1, 2)
Пример #12
0
def FlatToImg(X, w, h, c):
	if not numpy_array(X):
		X = np.asarray(X)	
	return X.reshape(-1, w, h, c)