import tensorflow as tf import matplotlib . pyplot as plt from tensorflow.keras import datasets, layers, models, losses ( x_train , y_train ), ( x_test , y_test )= tf .keras.datasets.mnist.load_data() x_train = tf .pad( x_train , [[ 0 , 0 ], [ 2 , 2 ], [ 2 , 2 ]])/ 255 x_test = tf .pad( x_test , [[ 0 , 0 ], [ 2 , 2 ], [ 2 , 2 ]])/ 255 x_train = tf .expand_dims( x_train , axis = 3 , name = None ) x_test = tf .expand_dims( x_test , axis = 3 , name = None ) x_train = tf .repeat( x_train , 3 , axis = 3 ) x_test = tf .repeat( x_test , 3 , axis = 3 ) x_val = x_train [- 2000 :,:,:,:] y_val = y_train [- 2000 :] x_train = x_train [:- 2000 ,:,:,:] y_train = y_train [:- 2000 ] base_model = tf .keras.applications.ResNet152( weights = 'imagenet' , include_top = False , input_shape = ( 32 , 32 , 3 )) for layer in base_model .layers: layer .trainable = False x = layers.Flatten()( base_model .output) x = layers.Dense( 1000 , activation = 'relu'...
Comments
Post a Comment