Skip to content

Instantly share code, notes, and snippets.

View girija2204's full-sized avatar
🏠
Working from home

Girija Shankar Behera girija2204

🏠
Working from home
View GitHub Profile
@girija2204
girija2204 / cifar_load.py
Created July 20, 2020 03:59
load cifar data
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.cifar10.load_data()
# Normalizing the images
x_train_normalized, x_test_normalized = x_train/255.0, x_test/255.0
EPOCHS = 2
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(filters=32,kernel_size=(3,3),activation='relu',input_shape=(32,32,3)),
tf.keras.layers.MaxPooling2D((2,2)),
tf.keras.layers.Conv2D(filters=64,kernel_size=(3,3),activation='relu'),
tf.keras.layers.MaxPooling2D((2,2)),
tf.keras.layers.Conv2D(filters=64,kernel_size=(3,3),activation='relu'),
train_tensor_slices = tf.data.Dataset.from_tensor_slices((x_train,y_train))
type(train_tensor_slices)
# tensorflow.python.data.ops.dataset_ops.TensorSliceDataset
image, label = next(iter(train_tensor_slices))
labels[label.numpy()[0]]
# ‘frog’
train_tensor_slices_list = list(iter(train_tensor_slices))
def normalize(image,label):
return tf.cast(image,tf.float32)/255.0, label
x, y = normalize([243,225,297],2)
x.numpy(), y
# (array([0.9529412 , 0.88235295, 1.1647059 ], dtype=float32), 2)
train_tensor_slices = train_tensor_slices.map(normalize).batch(128)
@girija2204
girija2204 / cifar_model_on_tensorslices.py
Last active July 25, 2020 14:42
Creating a model on the tensor slices
logs = "logs/"+datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
# Profiling on batches 200 to 220
tfboard_callback = tf.keras.callbacks.TensorBoard(
log_dir=logs,
histogram_freq=1,
profile_batch='200,220'
)
history_dataset = model.fit(
train_tensor_slices,
train_tensor_slices = train_tensor_slices.batch(128).map(normalize)
train_tensor_slices = train_tensor_slices.batch(128).map(normalize).prefetch(buffer_size=tf.data.experimental.AUTOTUNE)
train_tensor_slices = train_tensor_slices.batch(128).map(normalize,num_parallel_calls=tf.data.experimental.AUTOTUNE).prefetch(buffer_size=tf.data.experimental.AUTOTUNE)
train_tensor_slices = train_tensor_slices.batch(128).map(normalize,num_parallel_calls=tf.data.experimental.AUTOTUNE).cache().prefetch(buffer_size=tf.data.experimental.AUTOTUNE)
@girija2204
girija2204 / satellite_3hours_images.py
Last active September 1, 2020 04:29
Showing satellite images within 6 hours
map = gis.map()
map.add_layer(landsat_data) # printing the whole data on the map
# Selecting the imageries collected on a single day from 2020-08-01 00:00:00 to 2020-08-02 00:00:00
features = landsat_data.layers[0].query(time_filter=[datetime(2020,8,1,00,00,00),datetime(2020,8,2,00,00,00)], order_by_fields="AcquisitionDate")
features # <FeatureSet> 375 features, or imageries collected on a single day
features.sdf.head() # sdf converts it into a spatial data frame, prints first 5 rows of the dataframe
# printing the imageries on the map
map = gis.map()