ONNX – Giving Developers the Freedom to Explore New AI Frameworks

Developers are always on the quest to create increasingly more advanced deep learning models using different frameworks that give them more variety of choice. A new deep learning model representation called Open Neural Networks Exchange Format (ONNX) was created to do just that. ONNX was co-created by Microsoft and Facebook as an open source project in 2017, and it continues to be adapted and supported by a community of partners.The most important features of ONNX are its framework interoperability and shared optimization, which allows developers to easily move between different machine learning frameworks depending on the task. ONNX makes it easier and faster for optimization even if they are integrated in different frameworks.

A good example of the flexibility of ONNX is looking at how a Keras model can be converted to it. Keras is a high-level neural networks API that can run on top of TensorFlow. It is written in Python, and is easy to learn and use.

To accomplish this, we would need the following:

  1. Python 3
  2. Numpy
  3. Keras and a Tensorflow
  4. ONNX

Below is a sample Convolutional Neural Network (CNN) from the Keras documentation:

import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
batch_size = 128
num_classes = 10
epochs = 2
# input image dimensions
img_rows, img_cols = 28, 28
# the data, split between train and test sets
(x_train, y_train), (x_test, y_test) = mnist.load_data()
if K.image_data_format() == ‘channels_first’:
x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
input_shape = (1, img_rows, img_cols)
x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
input_shape = (img_rows, img_cols, 1)x_train = x_train.astype(‘float32’)
x_test = x_test.astype(‘float32’)
x_train /= 255
x_test /= 255
print(‘Model Input shape:’, input_shape)
# convert class vectors to binary class matrices
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
model.add(Conv2D(64, (3, 3), activation=‘relu’))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dense(128, activation=‘relu’))
model.add(Dense(num_classes, activation=‘softmax’))
model.fit(x_train, y_train,
validation_data=(x_test, y_test))

At the end at the example we added a model.save, as shown in figure 1 below. Models in Keras are saved with the HDF5 file format.


Figure 1

Converting the model.

ONNX can be used through the command line or libraries in Python. We will be working with ONNX through Python. To be able to convert the Keras model to ONNX we need to import ONNXMLTools and from Keras the load_model function, as shown in Figure 2.

import onnxmltools
from keras.models import load_model

Figure 2

Then, we define the paths of our model.h5 file and the path of the output ONNX model. In Figure 3 we see an example.

# Update the input name and path for your Keras model
input_keras_model = ‘model.h5’
# Change this path to the output name and path for the ONNX model
output_onnx_model = ‘model_keras.onnx’

Figure 3

Now, we load the Keras model, as shown in Figure 4.

# Load your Keras model
keras_model = load_model(input_keras_model)

Figure 4

Finally, we convert the model calling the convert_keras function, as shown in Figure 5.

# Convert the Keras model into ONNX
onnx_model = onnxmltools.convert_keras(keras_model)
# Save as protobuf
onnxmltools.utils.save_model(onnx_model, output_onnx_model)

Figure 5

To load and test the ONNX model, run the code below to see its input shape. These are the same steps that would be taken to create a model in Keras.

import onnxruntime as rt
import numpy as np
sess_1 = rt.InferenceSession(‘keras_model. onnx’)
print(“The model expects input shape:”, sess_1.get_inputs()[0].shape)

Figure 6

Based on the example above, it’s clear that converting models to ONNX is pretty straight-forward and easy to understand. From our work here at Wovenware, we are finding that ONNX provides yet one more development model for deep-learning algorithms that are changing the way our customers solve their critical business challenges.

Taking the Bias out of AI Algorithms Begins with Diversity

A recent article I wrote for the Forbes Technology Council brought up the growing need for building diversity into AI algorithms in order to prevent biased decision-making. This is a subject that is getting heated attention among businesses, industry pundits and the media alike and stories about the consequences of biased AI abound.

As I mentioned in the article, as more organizations rely on algorithms to help with decisions making, we have a responsibility to ensure that we are not programming bias into our AI systems. A recent report released by AI Now Institute at New York University found pervasive biases in the AI industry, which is predominately comprised of white males. A major concern is that the bias that has crept into so many of our policies and practices in hiring, education and mortgage lending, are being programmed into AI apps.

Some of this bias can happen when data that is used in AI is based on a homogenous group. Take for example the pharma industry. In the past, pharma companies often tested drugs only on male subjects, operating under the fallacy that the results would apply to women as well. What they learned was that these studies were of limited value for women because they metabolized drugs differently than men. Because of this, eight drugs that had been approved by the FDA had to be taken off the market in a four-year span in the late 90’s/early 2000’s because, while they had not caused serious issues for men, they posed “unacceptable health risks to women.”

This realization that diverse teams achieve better outcomes than homogeneous ones is really hitting home. A study conducted by McKinsey found that public companies that were in the top 25 percent of ethnic and racial diversity had a better chance of outperforming their peers, with a 33 percent greater probability of achieving above-average returns. Whether it’s pricing stocks or determining guilt or innocence in a trial, a diverse group is more likely to examine the facts, be objective and be more accurate.

The AI ecosystem is no different than the real world – diversity is the well-spring to well-functioning algorithms and requires diverse data-sets, as well as diverse groups of data scientists to create realistic solutions.

So how do you build in this diversity in AI development? At Wovenware, diversity is a central focus. It’s not enough to have highly trained data scientists and data engineers, but it’s also important to have a diverse group of staff reflecting a variety of backgrounds, experiences and perspectives to teach AI algorithms the nuances and insights they need to learn and predict more accurately.

We can’t allow the discrimination and biases of the real world to be mirrored in the AI one, but we must train our AI solutions to operate on a diverse and more level playing field.

World Class Software Learns from Regulated Industries

World class software is a term to describe the quality of software development that Wovenware promotes and delivers. World Class Software not only follows the industries best practices, but also innovates during the process. This type of development demands that the solutions developed are future proof and easily scalable within any scenario. The architecture must be simple to implement and flexible enough to evolve through time. It is software developed with security as one of the main goals so that potential vulnerabilities are detected and corrected early in the development by implementing software helping deliver a complete robust system.

The visionaries behind a World Class Software is the world class team working during the development lifecycle. Before this team goes to work, the first thing we have to learn are the guidelines that make up a World Class Software. Unfortunately, a detailed list defining what makes a World Class Software does not exist, but there are a couple of regulations that help paint a clear picture towards what World Class Software should aim for. Along with these regulations comes the Regulated Industries that these regulations are for. There are a couple of regulated industries that have complex and robust guidelines towards information security, information management, forensic and audit processes, procedure, and technology management.

Regulated Industries are businesses that their line of work require them to follow government rules to operate. Some of these regulated industries include: education, financial, human resources, health care, and telecommunications. These government rules provide guidelines to define the minimum standards that World Class Software should follow. These guidelines provide insight towards features that the software should contain, how data must be managed, what the software should do, how they should behave, and how they should be maintained. An example of a non-technical regulation is the Jeany Cleary Act, which is a federal regulation requiring Higher Level Education institutions to disclose crime and security statistics. This kind of regulation helps a developer identify the type of information the system needs to be able to gather and process.

The financial industry has an interesting regulation regarding the use of federal tax information (FTI). The complexity involved in working with FTI data requires any developer to read IRS Pub. 1075 to fully grasp robustness of what needs to be developed. IRS Pub 1075 fully details what a robust and complete audit system must contain in order to deliver better results and error free software. On the other side, HIPAA privacy rule establishes clear guidelines on how to de-identify and manage health information. This type of regulation insides over the design process of a software because they provide considerations into the way data should be stored. Generally, regulations will not specify the exact details of how the rules should be implemented during the development, they provide a general overview of what should be done in order to comply. Although these could represent a challenge, it’s up to the developer to embrace the challenge and innovate to outperform.

When working with regulated industries, challenges do arise at any moment. The operations of these industries can change overnight with the stroke of a pen in Congress, local State Legislature or Senate. While these challenges present themselves, the important thing to remember is that when a challenge appears, an opportunity for innovation arises. Innovation does not have to happen only in technology. Technology can promote the innovation of processes and help streamline the workload pushing an industry to operate better and within compliance.

Regulations not only include government laws and statutes. Business and organizations in a regulated industry create their own internal regulations and procedures for operations. These internal rules and directives expand on the government regulations and very often they provide even clearer guidelines to follow. More so, these internal regulations can have the effect of creating technical documentation and procedures to be followed by the development teams during and after the implementation of the solution.

The following list contains several of U.S. Government regulations that intends to serve as repository for regulations to aid any developer in the creation of World Class Software:

  1. Computer Security Act of 1987 (40 USC 759)
  2. Federal Manager’s Financial Integrity Act (31 USC 3512)
  3. Paperwork Reduction Act of 1995 (44 USC 3501)
  4. Executive Order 12958 – Classified National Security Information
  5. HIPAA/HITECH 2009
  6. IRS Pub. 1075
  7. FIPS PUB 112 – Standard on Password Usage

The one thing I would like people to take from this post is that you do not have to work in a government regulated industry to apply the knowledge acquired from these rules. Now that the world-class team has armed themselves with the knowledge found in regulations, it is time to start analyzing requirements and design with this knowledge at hand. The real innovation starts with a high level view of the details that entail developing World Class Software.

Team Building Can Indeed Be a Day at the Beach

On October 11 we held our annual Wovenware employee outing at the beautiful Condado Lagoon in San Juan, where VIP Adventures Puerto Rico showed us what it takes to rely on the whole team to reach goals – whether that be completing a relay race by walking on planks, or playing problem-solving games on the shoreline.

What is amazing is that since we started holding these team-building outings for employees 12 years ago, Wovenware numbered only a few dozen employees – at best. This year’s event included all of our employees numbering in the hundreds. The growth and sheer size of our company makes it more important than ever to reinforce the core values upon which our company was built – Passion, Professionalism, Openness, Quality, Value, Fun, and Discipline.

At Condado Lagoon our day started early and we were split up into groups to compete against each other in a number of core activities, such as building structures out of a handful of materials, to solving problems as a team. Make no mistake, the day also included kayaking, paddle-boarding and other water sports, as well as eating and relaxing on the beach.

But more than just getting to know each other and proving our ability to compete, team-building outings such as this one help to bring our core values and mission to life. Wovenware is committed to becoming a world-class leader in artificial intelligence and nearshore software development. Meeting this goal requires building a team of problem solvers who are equally as committed to helping our customers explore all angles to meet their key business goals. It also requires a team of experts who can each bring their unique skill-sets to the table.

While this is our only outdoor outing, we try to hold other team-building events for our employees throughout the year, such as regular game nights, programmer’s day, movie nights, social responsibilities activities and “ice-breakers,” that provide a chance for employees to get to know each other. Bringing employees together like this gives them a chance to meet, since their specific jobs may never give them the chance to speak to each other.

We’re already planning for next year’s outing and I’m sure there are team members today honing their paddle-boarding or problem-solving skills to emerge as a winner at next year’s event. What they may not know is that they are already winners. By working together every day in teams, keeping Wovenware’s core mission at the front and center of their activities and relying on their team mates to complement each other, they’re contributing significantly to the success of Wovenware.

Condado Lagoon was the perfect place and Wovenware staff were the perfect participants to show that when nature, passion, enthusiasm and fellowship come together, all things are possible.

Moving On Up with New Corporate Headquarters

We were thrilled last month to make the move into our new corporate offices on Calle Los Angeles in San Juan. It was clear at the beginning of the year that we were bursting at the seams and needed to look for a bigger home to accommodate our expanding staff. The new space — a 13,000 square-foot facility – is triple the size of our former headquarters.

Wovenware Office Photos

Wovenware Office Photos

But it’s much more than just extra space. We wanted to foster an environment for collaboration, inspiration and a great employee experience, and we did just that. The new location features common areas, standing desks, a vertical garden, and even a massage room, among many other things. And, since we lease the space in the central offices of San Juan’s Department of Recreation and Sports, another big perk is our easy access to sporting fields, basketball courts, a gym and walking areas.

As our CEO, Christian Gonzalez points out in a recent article about the move in El Nuevo Día, “it’s like a campus, but in the middle of the city.” Some employees are even calling it Wovenplex, referring to Google’s corporate headquarters known as Googleplex.

While we’re proud of our new corporate home, we’re prouder of what it represents. It really is a sign of our growth and success over the past few years, despite obstacles such as devastating hurricanes and other challenges in Puerto Rico. It demonstrates that there is a growing need for the types of AI and software development services we offer, as well as the growing awareness that nearshoring these services to companies like ours can provide incredible value for organizations across the U.S. and around the world.

A lot has been written about the devastating impact that Hurricane Maria and the recent economic instability have had on Puerto Rican businesses, the reality is that some industry segments, like software development and manufacturing, are thriving because of our location, not in spite of it – we know that’s the case with Wovenware.

Thanks to our new headquarters, our staff has the space to collaborate, explore and envision new ways to help our customers succeed. A comfortable workplace can help to foster that, but we recognize that our real treasure comes from the people under its roof.

Is Your AI Program Emotionally Intelligent?

There is no doubt about it — it seems like we’re interacting with AI apps all day long in our business and our personal lives. This is spurring the growing demand for AI to “understand” how we are feeling and to be able to respond to us appropriately. A recent article I wrote for Forbes discusses this industry focus known as emotion AI, or “affective computing,” in which AI programs can recognize, interpret, process and simulate human emotions. In the article I address the possibilities that Emotion AI can deliver and the limitations that must be overcome in order to develop these types of smart – and emotionally intelligent — programs.

We can see the beginnings of Emotion AI in action with chatbots, which are based on Natural Language Processing (NLP). Some are trained to hear the emotion in a customer’s voice inflections to determine, for example, if he/she is angry or frustrated, as well as by the choice of words that are used. But since there are many ways to express anger and other emotions, a very large dataset is needed to train AI programs to accomplish this.

There are many exciting possibilities for Emotion AI on the horizon. Imagine if an AI healthcare app can identify mental or physical illness based on the way a patient looks or sounds, a marketer can judge a person’s reactions to an ad, or a contact center AI app can route a call to a supervisor if the customer sounds annoyed to avoid further frustration. Emotion AI can provide a critical business edge and a much better customer experience.

While there’s still more work to be done, the possibilities are endless. We just might find ourselves someday having a heart-to-heart with a robot.