輸入TFとしてtensorflow から tensorflow 輸入keras #の電車:60K | 試験:10K (x、y)は、(x_test、y_test)= keras.datasets.mnist.load_data() x.shapeの y.shape
#0ブラック、255ホワイト x.min()、x.max()、 x.mean()
x_test.shape、y_test.shape
#0-9 10種類結果分類 y_onehot tf.one_hot =(Y、深さ= 10 ) y_onehot [: 2]
#電車:50K | 試験:10K (x、y)は、(x_test、y_test)= keras.datasets.cifar10.load_data()
x.shape、y.shape、x_test.shape、y_test.shape
x.min()、x.max()
DB = tf.data.Dataset.from_tensor_slices(x_test)
次(ITER(DB))。形
DB = tf.data.Dataset.from_tensor_slices((x_test、y_test))
次の(ITER(DB))[0] .shape
破壊データ DB = tf.data.Dataset.from_tensor_slices((x_test、android.permission.FACTOR。)) DB = db.shuffle(10000)
数据预处理 DEF 前処理(X、Y): X = tf.cast(X、DTYPE = tf.float32)/ 255 。 Y = tf.cast(Y、DTYPE = tf.int32) Y = tf.one_hot(Y、深さ= 10 ) 戻りX、Y DB2 = db.map(前処理) RES = 次(ITER(DB2)) RES [0 ] .shape、RES [ 1] .shape
ワンタイム複数の写真 DB3 = db2.batch(32 ) RES = 次に(ITER(DB3)) RES [0] .shape、RES [ 1] .shape
db_iter = ITER(DB3) しばらく真: 次の(db_iter)
REPEAT() #1 から出ることなく反復 DB4 = db3.repeat() #の出口に二回反復を DB3 = db3.repeat(2)
DEF prepare_mnist_features_and_labels(X、Y): X = tf.cast(X、tf.float32)/ 255 。 Y = tf.cast(Y、tf.int64) リターンX、Y DEF mnist_dataset(): (x、y)は、(x_val、y_val) = datasets.fashion_mnist.load_data() Y = tf.one_hot(Y、深さ= 10 ) y_val = tf.one_hot(y_val、深さ= 10 ) DS = tf.data.Dataset.from_tensor_slices((X、Y)) DS = ds.map(prepare_mnist_features_and_labels) DS = ds.shffle(60000).batch(100 ) ds_val =tf.data.Dataset.from_tensor_slices((x_val、y_val)) ds_val = ds_val.map(prepare_mnist_features_and_labels) ds_val = ds_val.shuffle(10000).batch(100 ) の戻り DS、ds_val