Articles on Trending Technologies

Technical articles with clear explanations and examples

What is a common debugging workflow while creating a model using Keras in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 235 Views

When developing machine learning models with Keras, a structured debugging workflow helps identify and resolve issues efficiently. Keras, part of TensorFlow, provides excellent tools for monitoring model construction and troubleshooting common problems during development. The TensorFlow package can be installed using the following command − pip install tensorflow Keras can be imported and accessed through TensorFlow − import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers Common Debugging Workflow The most effective debugging approach is to build models incrementally, checking each step. Here's a practical workflow − ...

Read More

How can Keras be used to create a model where the input shape of model is specified in advance?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 273 Views

Keras is a high-level deep learning API that runs on top of TensorFlow. When building neural networks, layers need to know the input shape to initialize their weights properly. Keras provides flexible ways to specify input shapes in advance. Understanding Layer Weight Initialization Keras layers create weights only when they know the input shape. This happens either when data is first passed through the layer or when the input shape is explicitly specified ? import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers print("Creating a dense layer without specifying input shape") layer ...

Read More

Check whether two strings are anagram of each other in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 529 Views

Two strings are anagrams if they contain the same characters with the same frequency, just rearranged. For example, "bite" and "biet" are anagrams because both contain one 'b', one 'i', one 't', and one 'e'. We'll explore three different methods to check if two strings are anagrams in Python. Method 1: Using Sorting The simplest approach is to sort both strings and compare them ? def check_anagram_sorting(s, t): if len(s) != len(t): return False ...

Read More

Check whether triangle is valid or not if sides are given in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 1K+ Views

To check if three sides can form a valid triangle, we use the triangle inequality theorem. This states that the sum of any two sides must be greater than the third side for all three combinations. For three sides a, b, and c, a triangle is valid if: a + b > c a + c > b b + c > a However, we can simplify this by sorting the sides first. If the sum of the two smaller sides is greater than the largest side, then all conditions are automatically satisfied. Algorithm ...

Read More

Check whether the two numbers differ at one-bit position only in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 601 Views

Suppose we have two numbers x and y. We have to check whether these two numbers differ at one-bit position or not in their binary representation. So, if the input is like x = 25 and y = 17, then the output will be True because x = 11001 in binary and y = 10001. Only one-bit position is different. Algorithm To solve this, we will follow these steps ? Calculate z = x XOR y Count the number of set bits in z ...

Read More

Check whether the sum of prime elements of the array is prime or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 286 Views

When working with arrays containing numbers, we often need to identify prime numbers and perform operations on them. This problem requires us to find all prime elements in an array, sum them up, and check if that sum is also prime. So, if the input is like nums = [1, 2, 4, 5, 3, 3], then the output will be True as sum of all primes are (2+5+3+3) = 13 and 13 is also prime. Understanding Prime Numbers A prime number is a natural number greater than 1 that has no positive divisors other than 1 and ...

Read More

Check whether the sum of absolute difference of adjacent digits is Prime or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 344 Views

Sometimes we need to check if the sum of absolute differences between adjacent digits in a number results in a prime number. This involves calculating differences between consecutive digits and testing if their sum is prime. Problem Understanding Given a number n, we need to ? Calculate the absolute difference between each pair of adjacent digits Sum all these differences Check if the sum is a prime number For example, if n = 574, then |5−7| + |7−4| = 2 + 3 = 5, which is prime, so the result is True. Algorithm ...

Read More

Check whether the point (x, y) lies on a given line in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 3K+ Views

To check whether a point (x, y) lies on a given line, we need to verify if the point satisfies the line equation. For a line in the form y = mx + b, where m is the slope and b is the y-intercept, we substitute the point's coordinates into the equation. If the equation holds true (left side equals right side), then the point lies on the line. Otherwise, it doesn't. Problem Example Given a line with slope m = 3 and y-intercept b = 5, we need to check if point (6, 23) lies on ...

Read More

Check whether the number formed by concatenating two numbers is a perfect square or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 324 Views

Sometimes we need to check if concatenating two numbers creates a perfect square. A perfect square is a number that can be expressed as the product of an integer with itself (like 16 = 4²). So, if the input is like x = 2 and y = 89, then the output will be True as after concatenating the number will be 289 which is 17². Algorithm To solve this problem, we will follow these steps − Convert both numbers to strings Concatenate the strings and convert back ...

Read More

Check whether the number can be made perfect square after adding 1 in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 676 Views

Given a number n, we need to check whether adding 1 to it results in a perfect square. A perfect square is a number that can be expressed as the product of an integer with itself (like 4 = 2², 9 = 3², 16 = 4²). For example, if n = 288, then n + 1 = 289, and 289 = 17², so the answer is True. Algorithm To solve this problem, we follow these steps ? Calculate res_num = n + 1 Find sqrt_val = integer part of square root of res_num If sqrt_val ...

Read More
Showing 5701–5710 of 61,299 articles
« Prev 1 569 570 571 572 573 6130 Next »
Advertisements