Angad Sandhu
Search
Browse

rps-exercise-question

Open In Colab

#@title Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
try:
  # %tensorflow_version only exists in Colab.
  %tensorflow_version 2.x
except Exception:
  pass
import tensorflow as tf
import tensorflow_datasets as tfds


def my_one_hot(feature, label):
    # Your code here to encode the labels to one-hot using tf.one_hot


data = tfds.load(# Your Code Here)
val_data = tfds.load(# Your Code here)

data = # Your code here to one_hot encode the labels
val_data = #Your code here to one_hot encode the labels


train_batches = data.shuffle(100).batch(10)
validation_batches = val_data.batch(32)

model = tf.keras.models.Sequential([
    tf.keras.layers.Conv2D(16, (3, 3), activation='relu', input_shape=#Your Code here),
    # Your code here to define the layers
    tf.keras.layers.Dense(#Your Code here)
])

model.summary()

model.compile(#Your Code Here)

history = model.fit(train_batches, epochs=10, validation_data=validation_batches, validation_steps=1)

Browse the library