결론은 np.set_printoptions(threshold=np.inf, linewidth=np.inf) 해주면 된다.
텐서플로우 예제코드 스터디 중이다.
from __future__ import absolute_import, division, print_function
import tensorflow as tf
import numpy as np
num_classes = 10
num_features = 784
learning_rate = 0.01
training_steps = 1000
batch_size = 256
display_step = 50
from tensorflow.keras.datasets import mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
print(type(x_train))
x_train, x_test = np.array(x_train, np.float32), np.array(x_test, np.float32)
print(x_train)
#np.set_printoptions(threshold=784,linewidth=np.inf)
#print(x_train[0])
Mnist load가 됐는지 확인해보기 위해 array를 출력해봤는데 아래와 같이 출력 되었다.
그런데 빈 행렬이 출력되는줄 알고 y는 어떤가 하고 봤는데 잘 출력되었다.
뭐지 하고 생각하다보니 로드한 데이터의 코너부분들은 거의다 0이 겠구나 싶어서 행렬 전체를 출력하는 법을 찾아보았다.
맨위의 소스코드에서 주석처리한 np.set_printoptions(threshold=784,linewidth=np.inf)를 추가해주면 된다.
threshold=784개가 넘는 원소를 갖는경우 축약형으로 출력해주는 속성이고 linewidth는 한줄에 출력되는 원소 숫자이다.
이 둘의 속성을 변경해주면 아래와 같이 잘 출력이 된다. 근데 x_train은 수가 많아서 한개만 출력하였다. x_train[0]
아래는 해당함수 메뉴얼이다.