Found 33676 Articles for Programming

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

165 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

How to get website links using Invoke-WebRequest in PowerShell?

Chirag Nagrekar
Updated on 18-Jan-2021 07:29:34

4K+ Views

To get the links present on the website using PowerShell, we can first retrieve the data from the webpage using the Invoke-WebRequest cmdlet.$req = Invoke-WebRequest -uri "https://theautomationcode.com" $reqOutputTo retrieve only links we can use that property and there you will also find some sub-properties like InnerHTML, Innertext, href, etc as shown in the output.$req = Invoke-WebRequest -uri "https://theautomationcode.com" $req.LinksOutputinnerHTML : Scripts innerText : Scripts outerHTML : Scripts outerText : Scripts tagName : A href : https://theautomationcode.com/scripts/ We need only links so we will use the href property.$req.Links | Select -ExpandProperty hrefOutputhttps://theautomationcode.com/2020/11/ https://theautomationcode.com/author/chiragce17/ ... Read More

Diameter of a Binary Tree in O(n) [A new method] in C++?

AmitDiwan
Updated on 16-Jan-2021 10:58:03

388 Views

The diameter of a binary tree is the (left_height + right_height + 1) for each node. So in this method we will calculate (left_height + right_height + 1) for each node and update the result . The time complexity here stays O(n).Let us first define the struct that would represent a tree node that contains the data and its left and right node child. If this is the first node to be created then it’s a root node otherwise a child node.struct Node {    int data;    struct Node *leftChild, *rightChild; };Next we create our newNode(int data) function that ... Read More

Diagonally Dominant Matrix in C++?

AmitDiwan
Updated on 16-Jan-2021 10:34:57

380 Views

A matrix is said to be diagonally dominant matrix if for every matrix row, the diagonal entry magnitude of the row is larger than or equal to the sum of the magnitudes of every other non-diagonal entry in that row.Let us first define a constant int variable N with value 3 which represents our matrix dimensions.const int N = 3;The isDDM(int mat[N][N], int n) is a Boolean function that takes a copy of our matrix and the size of our matrix. Inside we iterate the rows and columns of our matrix using nested for loop. We then find the sum ... Read More

Diagonal Traversal of Binary Tree in C++?

AmitDiwan
Updated on 16-Jan-2021 10:28:18

249 Views

To consider the nodes that are passing between lines of slope -1. The diagonal traversal of the binary tree will be to traverse and print all those nodes present between these lines.Let us first define the struct that would represent a tree node that contains the data and its left and right node child. If this is the first node to be created then it’s a root node otherwise a child node.struct Node {    int data;    struct Node *leftChild, *rightChild; };Next we create our createNode(int data) function that takes an int value and assign it to the data ... Read More

Diagonal Sum of a Binary Tree in C++?

AmitDiwan
Updated on 16-Jan-2021 10:24:39

186 Views

To consider the nodes that are passing between lines of slope -1. The diagonal sum of the binary tree will be calculated by the sum of all nodes data that are present between these lines of reference.Let us first define the struct that would represent a tree node that contains the data and its left and right node child. If this is the first node to be created then it’s a root node otherwise a child node.struct Node {    int data;    struct Node *leftChild, *rightChild; };Next we create our createNode(int data) function that takes an int value and ... Read More

Diagonal of a Regular Pentagon in C++?

AmitDiwan
Updated on 16-Jan-2021 10:19:00

119 Views

To find the length for the diagonal of a regular pentagon we put the value of side in (1+√5)side/2 = (1+2.24)side/2.ExampleLet us see the following implementation to get the regular Heptagon diagonal from its side − Live Demo#include using namespace std; int main(){    float side = 5;    if (side < 0)       return -1;    float diagonal = (1+2.24) *(side/2);    cout

Diagonal of a Regular Hexagon in C++?

AmitDiwan
Updated on 16-Jan-2021 10:16:44

162 Views

The regular hexagons are comprised of six equilateral triangles so the diagonal of a regular hexagon would be 2*side.ExampleLet us see the following implementation to get the regular Heptagon diagonal from its side − Live Demo#include using namespace std; int main(){    float side = 12;    if (side < 0)       return -1;    float diagonal = 2*side;    cout

DFA for Strings not ending with “THE” in C++?

AmitDiwan
Updated on 16-Jan-2021 10:14:31

370 Views

To use Deterministic Finite Automaton(DFA) to find strings that aren’t ending with the substring “THE”. We should keep that in mind that any variation of the substring “THE” like “tHe”, “The” ,”ThE” etc should not be at the end of the string.First, we define our dfa variable and initialise it to 0 which keeps our track of state. It is incremented on each character matched.int dfa = 0;The begin(char c) method takes a character and checks if its ‘t’ or ‘T’ and go to first state i.e 1.void begin(char c){    if (c == 't' || c == 'T')   ... Read More

DFA based division in C++?

AmitDiwan
Updated on 16-Jan-2021 10:08:29

242 Views

The Deterministic Finite Automaton(DFA) is used for checking if a number is divisible by another number k or not. The algorithm is useful because it can also find the remainder if the number isn’t divisible.In DFA based division we build a DFA table with k states. We consider binary representation of the number so there is only 0 and 1 in each state in DFA.The createTransTable(int k, int transTable[][2]) function is used for creating the transTable and storing the states in it. It takes the number k by which the number is to be divisible and transTable[][2] which is an ... Read More

Advertisements