from utils import Reduction, distributed, make_grid, make_citation
import utils as utils
load_dataset
batch() にdrop_remainder=Trueを設定
trainset = tf.data.Dataset.from_tensor_slices(trains).map(
lambda *args: [preprocess(a) for a in args]
).shuffle(128).batch(batch_size,drop_remainder=True).prefetch(buffer_size=tf.data.experimental.AUTOTUNE)
val = np.load("test.npz", allow_pickle=True)
valset = tf.data.Dataset.from_tensor_slices((val["image"], val["mosaic"], val["mask"]))
valset = valset.map(
lambda *args: [preprocess(a) for a in args]
).batch(batch_size,drop_remainder=True).prefetch(buffer_size=tf.data.experimental.AUTOTUNE)
tensorflow 2.6.0で動かす場合、いくつか修正するとうまく動作しました。(10epochクリア / 88分) 参考に修正ポイントを記載します。
修正ポイント
TPUの初期化をする
メイン処理部分
インポート修正
utils_tf20 -> utils
load_dataset
batch() に
drop_remainder=True
を設定