NaiveDense 클래스와 NaiveSequential 클래스를 사용하여 케라스와 유사한 모델을 만들 수 있습니다.
= NaiveSequential([ NaiveDense(=28 * 28, =512, =tf.nn.relu), NaiveDense(=512, =10, =tf.nn.softmax) ]) assert len(.weights) == 4
배치 제너레이터
그다음 MNIST 데이터를 미니 배치로 순회할 방법이 필요합니다.
import math class BatchGenerator: def __init__(, , , =128): assert len() == len() . = 0 . = . = . = . = math.ceil(len() / ) def next(): = .[. : . + .] = .[. : . + .] . += . return ,