This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
physical_devices = tf.config.experimental.list_physical_devices('GPU') | |
for physical_device in physical_devices: | |
tf.config.experimental.set_memory_growth(physical_device, True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# output encoding | |
y = tensorflow.keras.utils.to_categorical(output_data, 2) | |
# shuffle all indexes | |
indexes = np.arange(2800) | |
np.random.shuffle(indexes) | |
X_train = X[indexes].transpose([0,2,3,1]) | |
y_train = y[indexes] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# download dataset from json object | |
f = open(r'./ships-in-satellite-imagery/shipsnet.json') #download at http://vipnas.buitrongan.com:5000/sharing/Gd1gOIi9A | |
dataset = json.load(f) | |
f.close() | |
input_data = np.array(dataset['data']).astype('uint8') | |
output_data = np.array(dataset['labels']).astype('uint8') | |
input_data.shape |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, sys, random | |
import numpy as np | |
import tensorflow as tf | |
import tensorflow.keras | |
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import Dense, Flatten, Activation | |
from tensorflow.keras.layers import Dropout | |
from tensorflow.keras.layers import Conv2D, MaxPooling2D | |
from tensorflow.keras.utils import to_categorical | |
from tensorflow.keras.optimizers import SGD |
NewerOlder