→ New → python3 → 파일명은 windowed_dataset

라이브러리 불러오기

import numpy as np
import tensorflow as tf

넘파이 배열 만들기

→ 차원을 미리 만들어 놓았음

x = np.arange(20)
x

차원 늘이기

tensorflow의 expand_dims(대상, 차원 수)를 하면 차원을 늘린다

tf.expand_dims(x, 1).shape

넘파이에서 차원 늘려주기

np.expand_dims(x, 1).shape

텐서플로우를 데이터셋으로 만들기

슬라이스 된 텐서를 데이터셋으로 만듦

ds = tf.data.Dataset.from_tensor_slices([1, 2, 3, 4, 5])

for d in ds :
    print(d)

ds