Capitalize the First Letter of String in TypeScript

TypeScript Capitalize Strings

While working on a user form in a TypeScript application, I had to ensure that the string values, such as name and email, should be stored in Title case, also known as Proper case (Adam Smith). In the form, the user might enter the details in lowercase, and to ensure consistent capitalization, it was required … Read more >>

TensorFlow One-Hot Encoding

one_hot

As I was building a neural network to predict housing prices across different U.S. states, I hit a roadblock. My model couldn’t make sense of the state names in my dataset. That’s when I remembered: neural networks don’t understand categorical data like “California” or “Texas” directly. This is where one-hot encoding comes to the rescue. … Read more >>

Convert Tensor to NumPy in TensorFlow

tensorflow tensor to numpy

Have you ever been working with TensorFlow and needed to use your tensor data in a non-TensorFlow environment? I’ve been there many times during my decade-plus career as a Python developer. One of the most common operations I perform is converting TensorFlow tensors to NumPy arrays. This conversion is essential when you need to use … Read more >>

How to Iterate Over Tensor in TensorFlow

iterating over a symbolic `tf.tensor` is not allowed

While I was working on a deep learning project, I needed to access and manipulate individual elements within TensorFlow tensors. The challenge was that tensors are not as simple to iterate over as regular Python lists. After spending hours experimenting with different approaches, I discovered several effective methods to iterate over tensors in TensorFlow. In … Read more >>

Subtract Days From a Date in TypeScript

Subtract days from date in Typescript using library

Recently, while working on a TypeScript project, I needed to find a date a few days before an important event, like when to start preparing or send reminders. If I had changed the dates directly, it could have caused issues in the code. So, I created a reusable function that subtracts days using TypeScript’s Date … Read more >>

How to Check if a Value Exists in an Enum in TypeScript?

Check if a Value Exists in an Enum in TypeScript

While building an e-commerce application in TypeScript, you might define a ProductCategory enum for valid categories like ‘electronics’, ‘clothing’, and ‘food’. When receiving data from a user or an API, it’s important to check if the provided category actually exists in the enum. This prevents invalid values from being processed or stored. This ensures your … Read more >>

How to Use TensorFlow get_shape() Function

get shape of tensor

Recently, I was working on a neural network project for predicting housing prices in California, and I needed to verify the dimensions of my tensors at various stages of the model. That’s when I realized how important TensorFlow’s get_shape() function is for debugging and building robust machine learning models. In this article, I’ll show you … Read more >>

Binary Cross Entropy in TensorFlow

binary cross entropy tensorflow

While working on a machine learning project, I needed to train a neural network for binary classification. The crucial decision was selecting the right loss function, and Binary Cross Entropy (BCE) emerged as the perfect choice. In this article, I’ll cover everything you need to know about implementing and optimizing Binary Cross Entropy in TensorFlow, … Read more >>

TensorFlow Convert String to Int

tensor to int

Working with TensorFlow often requires converting data between different types, and one of the most common conversions is from string to integer. I’ve encountered this need countless times in my decade of Python development experience. In real-world machine learning projects, data rarely comes in the perfect format. Sometimes you’ll get text data that needs to … Read more >>

TensorFlow Variables

tf variable tensorflow

Recently, I was working on a deep learning project where I needed to build a model that could predict housing prices in the US market. One of the fundamental concepts I had to master was how to properly use TensorFlow variables. The issue is, many tutorials don’t properly explain when and how to use variables … Read more >>