O'Reilly logo

Deep Learning with TensorFlow by Ahmed Menshawy, Md. Rezaul Karim, Giancarlo Zaccone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Source code for emotion classifier

In the following code, we have quoted the source code of the implemented emotion classifier:

import tensorflow as tf import numpy as np import os, sys, inspect from datetime import datetime import EmotionDetectorUtils  FLAGS = tf.flags.FLAGS tf.flags.DEFINE_string("data_dir", "EmotionDetector/", "Path to data files") tf.flags.DEFINE_string("logs_dir", "logs/EmotionDetector_logs/", "Path to where log files are to be saved") tf.flags.DEFINE_string("mode", "train", "mode: train (Default)/ test")  BATCH_SIZE = 128 LEARNING_RATE = 1e-3 MAX_ITERATIONS = 1001 REGULARIZATION = 1e-2 IMAGE_SIZE = 48 NUM_LABELS = 7 VALIDATION_PERCENT = 0.1  def add_to_regularization_loss(W, b):  tf.add_to_collection("losses", tf.nn.l2_loss(W)) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required