May 31, 2024

[Tableau] Combining Multiple Date Fields

 

There was a question from my colleague on how to combine multiple date fields into one date field in Tableau.  This scenario is applicable when visualizations with different metrics use different date fields and you want to display only one date filter in the dashboard.


Tableau has this KB article which lists many options to resolve this issue.  However, there's also another way to resolve this by using UNION ALL in a custom query.  Here're the steps: 


1)  Step 1:  Create a custom query with UNION ALL and a [data_type] field based on different dates.

SELECT number, closed_date, created_date, sales, profit,

'Closed Date' as data_type

FROM table

UNION ALL

SELECT number, closed_date, created_date, sales, profit,

'Created Date' as data_type

FROM table


2)  Step 2:  Create a 'Date' formula in Tableau Desktop where the logic is when [data_type] = 'Closed Date', use [closed_date]. If data_type = 'Created Date', use [created_date].


@Date

DATE(CASE [data_type]

When 'Closed Date' then [closed_date]

When 'Created Date' then [created_date]

END)


3)  Step 3:  Create visualizations based on different dates.  For example, create viz1 as a line chart based on Closed Date.  Use the @Date formula as x-axis and filter for [data_type] = 'Closed Date'.  In the same viz1, include @Date in the Filters pane, which will be used as a common date filter among the different visualizations.  

Using the same procedure, create viz2 based on Created Date with [data_type] = 'Created Date'.


4) Step 4:  Create a dashboard with different visualizations.  Display @Date as filter, which now acts as a common date filter among the visualizations using different dates.


May 24, 2024

Tensor Cores

 

Tensor Cores are a key feature in NVIDIA’s GPU architecture that accelerates the GPUs’ computing performance for deep learning.  They are the processing subunits optimized for performing matrix multiplications and accumulations, essential operations in AI workloads.


Background


All semiconductor chips perform math operations (add, subtract, multiply, etc).  A tensor is a mathematical object that describes a multilinear relationship between sets of mathematical objects.  They are commonly shown as an array of numbers, where the dimension of the array is shown below.




                                0 dimension  = scalar

                               1 dimension  = vector

                               2 dimensions = matrix


Bonus:  Read here for excellent explanation of matrix multiplication.



Functionalities


Tensor Cores support mixed-precision computing, which involves using lower precision (e.g., FP16) for matrix multiplications and higher precision (e.g., FP32) for accumulation.  This approach balances performance and precision, allowing for faster computations without significant loss of accuracy.  


Tensor Cores can handle different data types, including FP16 (half-precision floating-point), BFLOAT16 (Brain Floating Point), INT8 (8-bit integer), and INT4 (4-bit integer).  This flexibility allows Tensor Cores to be used in a wide range of AI applications, from training large neural networks to performing efficient inference.



Key Features


AI models such as neural networks contain many layers and the computations running through these layers can be batched together to run in a single, large, matrix multiplication.  Tensor Cores significantly increase the throughput of these matrix operations.


Furthermore, by offloading intensive matrix operations to Tensor Cores, NVIDIA GPUs can achieve higher performance per watt, making them more energy-efficient compared to using general-purpose CUDA cores for the same tasks.


In summary, the specialized hardware Tensor Cores are a game-changing technology that provides unparalleled performance and efficiency for matrix operations.  They help to accelerate the generative AI evolution and thus, play a part in changing the future.



May 17, 2024

Information Theory & AI

 

Claude Shannon's Information Theory provides a rigorous framework and pragmatic concepts that are extensively utilized in artificial intelligence, including data representation, machine learning, data compression, communication, signal processing, generative modeling, and cryptography.


Let’s ask GPT-4 to explain the connection between Information Theory and AI.





May 10, 2024

Information Theory

 


Claude Shannon


As the AI evolution continues to accelerate, it’s important to revisit the past to pay homage to the contributions of the past generations from which the current AI advancement is built upon.  One of those giants is the American mathematician Claude Shannon, who wrote his landmark paper ‘A Mathematical Theory of Communication’, published in the Bell System Technical Journal in 1948.  This research paper transformed the understanding of communication systems by giving a mathematical structure to quantify information and its transmission.


Let’s discuss the important concepts in Shannon’s foundational paper.


1)  Information can be defined as a reduction of uncertainty.  If an event has high probability, its occurrence carries little information.  Whereas if an event has low probability, its occurrence has high information content.  For example, the probability of winning a jackpot is extremely small, so when the news is you win a jackpot, you will be very surprised by the outcome.  That is, information content increases with decreasing probability.


2)  Entropy:  Shannon introduced the concept of entropy to measure the uncertainty or randomness of a message source.  Just like the way we can measure the mass of an object in kilogram, information can be measured or compared using a measurement called entropy.  Entropy is like an information scale that shows how much information a message has.  Higher entropy implies higher unpredictability or information content.


3)  Channel Capacity:  Shannon discussed the notion of channel capacity as the maximum rate at which information can be reliably transmitted over a communication channel.  All communications must happen through a medium from a transmitter to a receiver.  If you’re in a loud room, then your message needs to be very loud and clear in order to be understood.  Whereas if you’re in a quiet room, your message might have some noise but it can still be understood.  Channel capacity is a theoretical limit to the amount of signal that you can pump through any given medium based on how noisy the medium is and the level of entropy in the message you’re trying to convey.  


4)  Data Compression aims to represent information in a more efficient manner by removing redundancy, thereby reducing the amount of data required to represent the same information.  If entropy of the information decreases due to known statistical structure, the ability to compress increases.  Whereas if entropy of the information increases due to unpredictability, the ability to compress decreases.  If we want to compress beyond entropy, we must be willing to throw away unnecessary information in our message.


In the next post, we'll explore the far-reaching impact of Shannon's Information Theory in the field of AI.



May 3, 2024

Diffusion Models vs. GANs

 

Now that diffusion models and GANs have been discussed in my previous posts, let's ask GPT-4 to summarize and compare the differences between these two models.