Found 10476 Articles for Python

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

AmitDiwan
Updated on 18-Jan-2021 10:57:07

127 Views

Tensorflow is a machine learning framework that is provided by Google. It is an open-source framework used in conjunction with Python to implement algorithms, deep learning applications and much more. It is used in research and for production purposes. It has optimization techniques that help in performing complicated mathematical operations quickly.This is because it uses NumPy and multi-dimensional arrays. These multi-dimensional arrays are also known as ‘tensors’.The ‘TensorFlow’ package can be installed on Windows using the below line of code −pip install tensorflowKeras means ‘horn’ in Greek. Keras was developed as a part of the research for the project ONEIROS ... Read More

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

AmitDiwan
Updated on 18-Jan-2021 10:54:51

168 Views

Tensorflow is a machine learning framework that is provided by Google. It is an open-source framework used in conjunction with Python to implement algorithms, deep learning applications and much more. It is used in research and for production purposes.Keras was developed as a part of the research for the project ONEIROS (Open-ended Neuro-Electronic Intelligent Robot Operating System). Keras is a deep learning API, which is written in Python. It is a high-level API that has a productive interface that helps solve machine learning problems.It runs on top of the Tensorflow framework. It was built to help experiment in a quick ... Read More

Check whether two strings are equivalent or not according to given condition in Python

Arnab Chakraborty
Updated on 16-Jan-2021 05:09:48

393 Views

Suppose we have two strings s and t of same size. We have to check whether s and t are equivalent or not. There are few conditions to check:They both are equal. Or, If we divide the s into two contiguous substrings of same size and the substrings are s1 and s2 and also divide t same like, s into t1 and t2, then one of the following should be valid:s1 is recursively equivalent to t1 and s2 is recursively equivalent to t2s1 is recursively equivalent to t2 and s2 is recursively equivalent to t1So, if the input is like ... Read More

Check whether two strings are anagram of each other in Python

Arnab Chakraborty
Updated on 16-Jan-2021 05:08:38

423 Views

Suppose we have two strings s and t we have to check whether they are anagram of each other or not.So, if the input is like s = "bite" t = "biet", then the output will be True as s ad t are made of same characters.To solve this, we will follow these steps −if size of s is not same as size of t, thenreturn Falsesort characters of s and treturn true if s is exactly same as t, otherwise falseLet us see the following implementation to get better understanding −Example CodeLive Demodef solve(s, t):    if len(s) != ... Read More

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

Arnab Chakraborty
Updated on 16-Jan-2021 05:06:08

912 Views

Suppose we have three sides. We have to check whether these three sides are forming a triangle or not.So, if the input is like sides = [14,20,10], then the output will be True as 20 < (10+14).To solve this, we will follow these steps −sort the list sidesif sum of first two sides

Check whether the vowels in a string are in alphabetical order or not in Python

Arnab Chakraborty
Updated on 16-Jan-2021 05:05:30

421 Views

Suppose we have a string s. We have to check whether the vowels present in s are in alphabetical order or not.So, if the input is like s = "helloyou", then the output will be True as vowels are e, o, o, u all are in alphabetical order.To solve this, we will follow these steps −character := character whose ASCII is 64for i in range 0 to size of s - 1, doif s[i] is any one of ('A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u'), thenif s[i] < character, thenreturn Falseotherwise, character := s[i]return TrueLet us see ... Read More

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

Arnab Chakraborty
Updated on 16-Jan-2021 05:04:43

497 Views

Suppose we have two numbers x and y. We have to check whether these two numbers differ at one-bit position or not.So, if the input is like x = 25 y = 17, then the output will be True because x = 11001 in binary and y = 10001. Only one-bit position is different.To solve this, we will follow these steps −z = x XOR yif number of set bits in z is 1, thenreturn Truereturn FalseLet us see the following implementation to get better understanding −Example CodeLive Demodef bit_count(n):    count = 0    while n:       ... Read More

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

Arnab Chakraborty
Updated on 16-Jan-2021 05:03:01

177 Views

Suppose we have an array nums. We have to check whether the sum of all prime elements in the given array is also prime or notSo, 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.To solve this, we will follow these steps −MAX := 10000sieve := a list of size MAX and fill with trueDefine a function generate_list_of_primes()sieve[0] := False, sieve[1] := Falsefor i in range 2 to MAX - 1, doif sieve[i] is true, thenfor ... Read More

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

Arnab Chakraborty
Updated on 16-Jan-2021 05:01:44

217 Views

Suppose we have a number n. We have to check whether the sum of the absolute difference of adjacent digit pairs is prime or not.So, if the input is like n = 574, then the output will be True as |5-7| + |7-4| = 5, this is prime.To solve this, we will follow these steps −num_str := n as stringtotal := 0for i in range 1 to size of num_str - 1, dototal := total + |digit at place num_str[i - 1] - digit at place num_str[i]|if total is prime, thenreturn Truereturn FalseLet us see the following implementation to get ... Read More

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

Arnab Chakraborty
Updated on 16-Jan-2021 05:00:59

2K+ Views

Suppose we have a straight line in the form y = mx + b, where m is slope and b is y-intercept. And have another coordinate point (x, y). We have to check whether this coordinate point lies on that straight line or not.So, if the input is like m = 3 b = 5 point = (6, 23), then the output will be True as if we put the given x and y coordinate values on the straight line equation then it will satisfy.To solve this, we will follow these steps −if y of point is same as (m ... Read More

Advertisements