Trending December 2023 # How To Use Excel Vba Or Function With Examples? # Suggested January 2024 # Top 16 Popular

You are reading the article How To Use Excel Vba Or Function With Examples? updated in December 2023 on the website Cattuongwedding.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 How To Use Excel Vba Or Function With Examples?

Excel VBA OR Function

Like a worksheet function excel VBA also has a logical function which is OR function. In any programming language OR function is defined as follows:

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Condition 1 OR Condition 2. If any of the given conditions happens to be true the value returned by the function is true while if both of the condition happens to be false the value returned by the function is false. OR Function can be termed as that it is opposite to AND function because in AND function both of the condition needs to be true in order to get a true value. Even if a single condition is termed as false then the whole value returned by the AND function is false. While in OR Function only one condition needs to be true in order to get TRUE as an output.

Syntax of OR Function in Excel VBA

VBA OR function has the following syntax:

{Condition 1} OR {Condition 2}

Let us use this function in VBA to have a clear mindset of how to use this function in general terms.

Note: In order to use VBA we need to have developer access enabled from the file tab.

How to Use Excel VBA OR Function?

We will learn how to use VBA OR Function with few examples in excel.

You can download this VBA OR Excel Template here – VBA OR Excel Template

Example #1 – VBA OR

Follow the below steps to use VBA Union function in Excel:

Step 1: Now once we are in VB Editor go ahead and insert a new module from the insert section.

Code:

Sub

Sample()

End Sub

Step 3: Define the four variables A B C and D as integers.

Code:

Sub

Sample()

Dim

A

As

Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

End Sub

Step 4: Define a variable X to store the value of OR Function, define it as a string.

Code:

Sub

Sample()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

Dim

X

As String

End Sub

Step 5: Assign Random Values to A B C and D.

Code:

Sub

Sample()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

Dim

X

As String

A = 10 B = 15 C = 20 D = 25

End Sub

Step 6: Define X’s Values as conditions for A B C and D.

Code:

Sub

Sample()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

Dim

X

As String

A = 10 B = 15 C = 20 D = 25

End Sub

Step 7: Now we will display the value of X stored in it.

Code:

Sub

Sample()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

Dim

X

As String

A = 10 B = 15 C = 20 D = 25 MsgBox X

End Sub

Step 8: Run the code from the run button provided in the screenshot below and then we see the following result when we run the above code.

Why we get the value as false because A is not greater than B and C is not greater than D. Both of the values of the condition were returned as false so our final output is also returned as false.

Example #2 – VBA OR

Step 1: Now once we are in VB Editor go ahead and insert a new module from the insert section.

Step 2: A code window will appear on the right-hand side of the screen. Define the subfunction as Sample1.

Code:

Sub

Sample1()

End Sub

Step 3: Define the four variables A B C and D as integers.

Code:

Sub

Sample1()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

End Sub

Step 4: Define a variable X to store the value of OR Function, define it as a string.

Code:

Sub

Sample1()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

Dim

X

As String

End Sub

Step 5: Assign Random Values to A B C and D.

Sub

Sample1()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

Dim

X

As String

A = 10 B = 15 C = 20 D = 25

End Sub

Step 6: Define X’s Values as conditions for A B C and D.

Code:

Sub

Sample1()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

Dim

X

As String

A = 10 B = 15 C = 20 D = 25

End Sub

Step 7: Now we will display the value of X stored in it.

Code:

Sub

Sample1()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

Dim

X

As String

A = 10 B = 15 C = 20 D = 25 MsgBox X

End Sub

Step 8: Run the code above from the run button as shown and we will see the following result as we run the above code.

Why we get the value as True because A is less than B and C is not greater than D. One of the values of the condition were returned as true so our final output is also returned as true.

Example #3 – VBA OR

Now let us use OR Function in VBA with the IF function. Earlier we used another variable to store the Boolean value of OR function and display it. This time we will use a personalized message to display using or and if function.

Steps 1: Now once we are in VB Editor go ahead and insert a new module from the insert section.

Step 2: A code window will appear on the right-hand side of the screen. Define the subfunction as Sample2.

Code:

Sub

Sample2()

End Sub

Step 3: Define all the four variables A B C and D as integers and assign them random values.

Code:

Sub

Sample2()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

A = 5 B = 10 C = 15 D = 20

End Sub

Step 4: Now write the if statement for the given variables, for example, like in the code given below,

Code:

Sub

Sample2()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

A = 5 B = 10 C = 15 D = 20

End Sub

Code:

Sub

Sample2()

Dim

A

As Integer

Dim

B

As Integer

Dim

C

As Integer

Dim

D

As Integer

A = 5 B = 10 C = 15 D = 20 MsgBox "One of the conditions is true"

Else

MsgBox "None of the conditions is true"

End If

End Sub

Step 6: Run the above code from the run button and we will get the following result displayed.

As one of the conditions were true we have the above result.

Example #4 – VBA OR

Let use VBA OR function in a real scenario. We have the following data, Name of the employees and sales done by them. If their sales are equals to specific criteria or greater than that then they will receive the incentive or there will be no incentive for those employees. Have a look at the data below,

The incentive criteria are 10000 for this example. If the sales done by the employees is equals to or above 10000 they will receive the incentive.

Steps 1: Now once we are in VB Editor go ahead and insert a new module from the insert section.

Step 2: In the code window, declare the subfunction,

Code:

Sub

Employee()

End Sub

Step 3: Declare a variable X as Long and write the if statement as below,

Code:

Sub

Employee()

Dim

X

As Long

For

X = 2

To

10 Cells(X, 3).Value = "Incentive"

Else

Cells(X, 3).Value = "No Incentive"

End If

End Sub

Step 4: Start the loop for the next cell.

Code:

Sub

Employee()

Dim

X

As Long

For

X = 2

To

10 Cells(X, 3).Value = "Incentive"

Else

Cells(X, 3).Value = "No Incentive"

End If

Next

X

End Sub

Step 5: Run the code to form the run button provided and once we have run the code check the result below,

In the If Statement, we used that if the sales are done is equals to 10000 or sales done greater than 10000 the employee will receive incentive.

Things to Remember

There are a few things we need to remember about VBA OR Function:

It is a logical function in excel or any other programming language.

It returns a logical output true or false.

It is the opposite of AND Function.

Recommended Articles

This is a guide to VBA OR. Here we have discussed how to use Excel VBA OR Function along with practical examples and downloadable excel template. You can also go through our other suggested articles –

You're reading How To Use Excel Vba Or Function With Examples?

How To Use Vba Union Function In Excel?

VBA Union

As the word itself suggests, union means joining one or more things. In VBA Union means joining two or more ranges together. This function is similar to the range function in excel. This is the most common situation in our work when we need to combine one or more ranges with each other. Union function comes in very handy in those situations.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

As explained above, VBA Union functions combine one or more ranges. We can use this function to combine ranges with some common criteria. For example, if our data has a value less than a specific value, we can use this function to combine those ranges and highlight them.

Syntax of VBA Union in Excel

The syntax for the Union function is as follows:

So, for example, if we want to combine a range A1: A5 and B1: B5, we will use the following formula,

Union (Range (“A1:A5”), Range (“B1:B5”)

First, let us ensure we have a developer’s tab enabled from the files tab in the options section to start using VBA in Excel.

How to Use VBA Union Function in Excel?

We will learn how to use a VBA Union function with a few examples in excel.

You can download this VBA Union Excel Template here – VBA Union Excel Template

Example #1 – VBA Union

In the first example, let us try to select two ranges together. Let us select A1:A5 and B1:B5 range together in this example.

Follow the below steps to use the VBA Union function in Excel:

Step 1: We need to open the VB editor from visual basic, which is in the developer’s tab.

Step 3: Once we are in the code window, name the macro as follows,

Code:

Sub

sample()

End Sub

Step 4: Since we will work with sheet 1, we must activate it first to use its properties.

Code:

Sub

 sample() Worksheets("Sheet1").Activate

End Sub

Step 5: Now, we will use the union function to combine the two ranges we have discussed above with the following code.

Code:

Sub

sample() Worksheets("Sheet1").Activate Application.Union(Range("A1:A5"), Range("B1:B5")).Select

End Sub

Step 6: Once we execute the code above, we can see in sheet 1 that those two ranges are in our selection. Press F5 or do it manually from the run button to see the result.

In the above example, we have only selected the two ranges, but we can do much more which we will learn in the next examples.

Example #2 – VBA Union

Now in this example, let us select two ranges as above together and change their interior color. We can change the format or change values once we combine and select the ranges together.

Code:

Sub

Sample1()

End Sub

Step 3: Now, let us activate sheet 2 first since we will use the properties of sheet 2 in this example.

Code:

Sub

Sample1() Worksheets("Sheet2").Activate

End Sub

Step 4: Combine two ranges, A1:B5 and C1:D5, with the range function and change the interior color to a dark red by the following code.

Code:

Sub

Sample1() Worksheets("Sheet2").Activate Application.Union(Range("A1:B5"), Range("C1:D5")).Interior.Color = 255

End Sub

Step 5: Execute the above and see the result in sheet 2 as follows,

After combining them, we have changed the color of the ranges as we can see that they are still in selection.

Example #3 – VBA Union

Now let’s use the union function to display the address after combining ranges. We will combine range A1:C4 and E1:F4 and display the address in the Immediate window. An immediate window is just below our code window, or we can press CTRL + G to bring it up.

Step 2: Name the macro name for this third example.

Sub

Sample2()

End Sub

Step 3: Declare two variables as a range in the next step as follows.

Code:

Sub

Sample2()

Dim

rng1

As

Range

Dim

item

As

Range

End Sub

Step 4: Now set an rng1 variable as the union of the range A1: C4 and E1: F4 as follows,

Code:

Sub

Sample2()

Dim

rng1

As

Range

Dim

item

As

Range

Set

rng1 = Union(Range("A1:C4"), Range("E1:F4"))

End Sub

Step 5: Now use for loop to bring the address of these cells from the combined ranges by the following code,

Code:

Sub

Sample2()

Dim

rng1

As

Range

Dim

item

As

Range

Set

rng1 = Union(Range("A1:C4"), Range("E1:F4"))

For

Each

item

In

rng1

Debug

.

Print

item.Address

Next

item

End Sub

Step 6: Once we run the above code, we can see the result in the immediate window as follows,

Application of VBA Union

The following syntax uses VBA union:

Expression.Union(range1, range2,…..)

Here we can use as many ranges as we require.

Things to Remember

There are a few things that we need to remember about the union in VBA:

The union is used to combine two or more ranges together.

The ranges we give to the function must exist to avoid an error.

Instead of Application. The union we can simply use the union as we are working in Excel itself.

Recommended Articles

This is a guide to VBA Union. Here we discuss how to use Excel VBA Union Function, practical examples, and a downloadable Excel template. You can also go through our other suggested articles –

How To Use If Function In Excel

Last Updated on September 5, 2023

The IF function is probably one of the most well-known formulas for Excel, as it allows for data points to be compared between a value and what you are expecting.

IF statements are powerful because you can have two results. The first result is going to inform you of whether your comparison is true. The second result will tell you whether your comparison is false.

Here are the basics of IF functions and how you can use them in Excel.

1

Example Of IF Function

In column 1 we have a list of Musical Artists, and in column 2 we have Total Album Sales. For reference, we would consider any album sales over 100,000 good, and any album sales over 200,000 excellent.

Step

1

If Function

If we begin to write “=if(“ into cell C5, you’ll see that it now says logical_test which would represent the Total Album Sales in the second column.

Step

2

Use Comparison Symbols

What this says is is the value of cell B5 greater than 100,000?

Step

3

Use A Reference Point

To make this process even easier, you can have cells that already have this value, and then simply use this cell as a reference point. For example, we already have the value 100,000 in cell C2, so we select this instead of writing 100,000.

Step

4

Use The F4 Key

You can also use the F4 key which will fix the column and row. So the formula will look like this:

If it is greater than 100,000, which in our example it is, then we need to follow up with our formula so that the cell will complete an action.

Step

5

Use Quotation Marks

We put a comma after the value of 1000,000 and then write “Good”. You must use quotation marks when working out of Microsoft Excel, otherwise use a predetermined cell instead.

Our example now looks like this, with the Good selection being used via cell D2:

To add to this, if you want the cell to do nothing if our Total Album Sales value is less than 100,000 we can simply put in a double quotation mark, whilst closing the bracket at the end of the formula.

This will look like this:

What will happen is that in our third column, if the value of an album sales exceeds 100,000 you will see the word Good appear in those columns, and for any albums that didn’t surpass the 100,000 mark, the cell will remain blank.

You can then use this formula to determine whatever data point you are looking to highlight.

Step

6

Add Different Labels

In our example, instead of looking for album sales over 100,000, we can look for album sales under 50,000 and make the IF function list them as Bad.

Or we could add different labels such as exceptional if an album went over 200,000 total sales.

Common Issues

There are a couple of common errors that will occur using the IF function. One example is that if you have a “0” value in the cell, this means that there was no argument or selection.

Or perhaps you see “#NAME?” in the cell. This represents that a formula has been misspelled, and as such you must make sure you not only use punctuation marks but also you spell your values correctly.

Final Thoughts

There are many more ways it can be used, but these are the basics. Which should hopefully guide you in the right direction.

How Map Function Works In Kotlin With Examples?

Introduction to Kotlin Map

Web development, programming languages, Software testing & others

Syntax

The kotlin language used many features as similar to java like collection, util package and even other packages classes and its method behaviours are the same as java. A map is one of the interfaces that can hold the datas as key-value pairs like java.

{ —–some coding logics it depends upon the application requirement— }

The above codes are the basic syntax for utilising the map interface on the kotlin. The mapping interface uses any type like Integer, String, Characters as the parameter type.

How does Map Function work in Kotlin?

A map is an interface that is used for to store the datas as the key-value pairs. Like java, it can be of the same type and feature. It’s worked in the kotlin. The key is the unique one, and it holds only a single value for each key; it also different pairs and combined with each other. It is the immutable one, and it is the fixed size, so after declaring the mapping size, it cannot be changed both static and dynamic. The members from the map interface are readable ones, so we cant edit and changeable for that. If we use the mutablemap interface, it supports both read and write access.

The key type is the invariant one, and it is accepted as the parameter; it uses a method like containsKey() and also it returns the keys set. Like that map value also covariant and its value type it also be changed if it’s required. The classes used on the map interface will be of any type; this is because of the classes used internally on the kotlin package. The map is of any type in the kotlin language; the key and value elements will be stored as a separate index; it takes the predicate arguments, the filter conditions will be of the negative type, and the key will be unique and it has many values.

Examples of Kotlin Map

Given below are the examples of Kotlin Map:

Example #1

Code:

package one; { val map = mapOf(1 to "Siva", 2 to "raman" , 3 to "Welcome", 4 to "To", 5 to "My Domain", 12 to "Its the twelth index and key value", 13 to "Its the thirteen index and key value", 14 to "Its the fourteen index and key value", 15 to "Its the fifteen index and key value") println( map) println("Its the first example for reagrding the kotlin map interface we used different classes and methods that can be related to the interface") val map1 = mapOf(6 to "Have a Nice Day users", 7 to "Its the Seventh index and key value" , 8 to "Its the eigth index and its key value", 9 to "Its the ninth index and its key value", 10 to "Its the tenth index and its key value", 11 to "Its the eleventh index and its key value") println("Thank you users for to spenting the time with our application your entries are : "+map1) println("Its the keys entries and it is used to store the variable : "+map1.keys ) println("Its the values the entries are used to store as the separate variable "+map1.values ) }

Output:

In the above example, we used a map interface, and it will store the user inputs as key-value pairs. We can use mapOf() method for to set the key values and print them accordingly.

Example #2

Code:

package one; { val first = mapOf("siva" to 1, 1 to "raman", 'A' to "Welcome To My Domain", "Have a Nice Day Users" to 'A') for ((k,v) in first) { println("Your input key is: $k and your input value is $v") } println("Your input key is: $k and your input value is $v") } println("Your input map size is: ${third.size}") println("Your input entries are: ${third.entries}") println("Your input key is: ${third.keys}") println("Your input values are: ${third.values}") println("Your Employeed ID is: ${third.get("Employee ID")}") println("Your Serial No is: ${third["SNO"]}") println("Your proofs are: ${third.getValue("ProofID")}") println("Your Employeed ID contains: ${third.containsKey("Employee ID")}") println("Your Serial No contains: ${third.contains("SNO")}") println("Your ProofID contains: ${"Chemistry" in third}") println("If any of the columns or attributes missing please add it separately: ${third.containsValue(1234566)}") println("The Additional or Missing attribute inputs are: ${third.getOrDefault("pincode",600063)}") }

Output:

Example #3

Code:

package one; { val third = mutableMapOf("Employee ID" to 1, 2 to "Employee Name", 3 to "Address", 4 to "City", 5 to "pincode") println(third) println(four) five.put("zipcode", 27346) println(five) five["SNo"] = 1234 println(five) five.putIfAbsent("landline", 91) five.putIfAbsent("MobileNumber", 2436) println(five) five.replace("Employee ID", 1) println(five) five.replace("Employee Name", 2, 3) println(five) five.remove("Address") println(five) five.remove("City", 4) println(five) five.clear() println(five) }

Output:

In the final example, we used a mutable map interface for to store the user inputs on key-value pairs. We used additional methods like remove(), replace(), clear() etc for to perform the operations.

Conclusion

In kotlin, we used a lot of collection util packages for to store, extract and retrieve the datas. Based on the requirements, we used specific util packages like map, list in a map we used a different set of interfaces and its methods for to implement the application which depends on the user requirements.

Recommended Articles

This is a guide to Kotlin Map. Here we discuss the introduction, syntax, and working of the map function in Kotlin along with different examples and code implementation. You may also have a look at the following articles to learn more –

How To Use Logstash Aws With Examples?

Introduction to Logstash AWS

Logstash AWS is a data processing pipeline that collects data from several sources, transforms it on the fly, and sends it to our preferred destination. Elasticsearch, an open-source analytics and search engine, is frequently used as a data pipeline. AWS offers Amazon OpenSearch Service (successor to Amazon Elasticsearch Service), a fully managed service that provides Elasticsearch with an easy connection with Logstash to make it easy for clients.

Start Your Free Data Science Course

What is Logstash AWS?

Create an Amazon OpenSearch Service domain and start loading data from our Logstash server. The Amazon Web Services Free Tier allows us to try Logstash and Amazon OpenSearch Service for free.

To make it easier to import data into Elasticsearch, Amazon OpenSearch Service has built-in connections with Amazon Kinesis Data Firehose, Amazon CloudWatch Logs, and AWS IoT.

We can also create our data pipeline using open-source tools like Apache Kafka and Fluentd.

All common Logstash input plugins, including the Amazon S3 input plugin, are supported. In addition, depending on our Logstash version, login method, and whether our domain uses Elasticsearch or OpenSearch, OpenSearch Service now supports the following Logstash output plugins.

Logstash output amazon es, signs, and exports Logstash events to OpenSearch Service using IAM credentials.

Logstash output OpenSearch, which only supports basic authentication at the moment. When building or upgrading to an OpenSearch version, select Enable compatibility mode in the console to allow OpenSearch domains.

We can also use the OpenSearch cluster settings API to enable or disable the compatibility of logstash.

Depending on our authentication strategy, we can use either the normal Elasticsearch plugin or the logstash output amazon es plugin for an Elasticsearch OSS domain.

Step-By-Step Guide logstash AWS

Configuration is comparable to any other OpenSearch cluster if our OpenSearch Service domain supports fine-grained access control and HTTP basic authentication.

The input for this sample configuration file comes from Filebeat’s open-source version.

Below is the configuration of the available search service domain as follows.

Code –

}

The configuration differs depending on the Beats app and the use situation.

All requests to OpenSearch Service must be signed using IAM credentials if our domain has an IAM-based domain access policy or fine-grained access control with an IAM master user.

In this scenario, the logstash output amazon es plugin is the simplest way to sign requests from Logstash OSS.

After configuring the available search service domain, we are installing the plugin name as logstash-output-amazon_es.

After exporting the plugin, we are exporting the IAM credential. And finally, we are changing the configuration files to use the plugin.

How to Use Logstash AWS?

Logstash provides several outputs that allow us to route data wherever we want, opening up a downstream application.

Over 200 plugins are available in Logstash’s pluggable structure. To work in pipeline harmony, mix, match, and orchestrate various inputs, filters, and outputs.

While Elasticsearch is our preferred output for searching and analyzing data, it is far from the only option.

We provide a great API for plugin development and a plugin generator to assist us in getting started and sharing our work.

The below step shows how to use logstash in AWS as follows.

The first step is to forward logs to OpenSearch Service using our security ports as 443.

The second step is to update the configurations for Logstash, filebeat, and OpenSearch Services.

The third step is to set up filebeat on the Amazon Elastic Compute Cloud instance we want to use as a source. Then, finally, check that our YAML config file is correctly installed and set up.

The fourth step is to set up Logstash on a separate Amazon EC2 instance to send logs.

Install logstash AWS

The below step shows install logstash on AWS as follows.

Create a new Ec2 instance –

In this step, we are creating a new instance of EC2 to install the logstash. In the below example, we have created the t2.micro instance.

Create a yum repository for installing the logstash –

In this step, we create the yum repository for installing the logstash in the Amazon EC2 instance.

[logstash-7.x] Type = rpm-md

Install the logstash on the newly created EC2 instance –

In this step, we install the logstash on a newly created instance using the yum command.

Start the logstash and check the status –

In this step, we are starting the logstash and checking the status of the logstash as follows.

# service logstash start

# service logstash status

Setup a Logstash Server for AWS

The below step shows the setup logstash for AWS as follows.

Create IAM policy –

Create a logstash configuration file –

}

Start the logstash and check the logs –

# service logstash start

Conclusion

Logstash AWS is a data processing pipeline that collects data from several sources, transforms it on the fly, and sends it to our preferred destination. Depending on our authentication strategy, we can use either the normal Elasticsearch plugin or the logstash-output-amazon_es plugin for an Elasticsearch OSS domain.

Recommended Articles

This is a guide to Logstash AWS. Here we discuss how to use logstash AWS, its installation and setup process, and a detailed explanation. You may also have a look at the following articles to learn more –

How To Use Pytorch Amd With Examples?

Introduction to PyTorch AMD

Web development, programming languages, Software testing & others

In this article, we will try to dive into the topic of PyTorch AMD and will try to understand What is PyTorch AMD, how to use PyTorch AMD, image classification models in AMD, its associated examples, and finally give our concluding statement on it.

What is PyTorch AMD?

PyTorch AMD is the container of the framework, allowing us to run the container of AMD’s machine learning framework. For doing so, it is necessary that the docker environment of your system should support the AMD GPU.

The minimum requirements of the single node server are that it should have X86-64 CPU or CPUs along with GPU(s) of AMD instinct MI100 and GPU of Radeon instinct MI50 (S). The operating system used for this should be Centos 8.3 or higher OR Ubuntu 18.04 or higher version. The driver for ROCm should be compatible with the 4.2 version, and the Docker Engine Singularity container is used at runtime.

By default, the considerations and suppositions made by PyTorch AMD container of frameworks are that the server should contain x-86-64 single or multiple CPUs and should have a minimum of one listing AMD GPU. Furthermore, to run the docker container, the server should have the listed ROCm driver with a specified or higher version installed on it and the required operating system. Finally, the server should contain the docker engine in it to run the container.

If you want to go for installing the Docker engine, kindly visit this link. In order to install singularity in its latest version, if the use of singularity is already planned, then visit this link. For installation of procedures of ROCm as well as validity checks, kindly go through this link.

How to Use PyTorch AMD?

AMD is an open-source platform and has high performance and flexibility. It comes along with various libraries, compilers, and languages that can be used by developers and communities working in Machine Learning, Artificial Intelligence, and HPC technology to make their task of coding easy, fast, and implementing complex logic and functionalities in it. The biggest task is that PyTorch AMD provides you with containers.

Docker pull “name of the container”

For example, for AMDih container of PyTorch, the command would be –

docker pull AMDih / PyTorch : rocm4.2_ubuntu18.04_py3.6_PyTorch_1.9.0 Image classification models in AMD

Broadly, image classification can be done by using either of the two technologies of PyTorch or tensorflow in AMD. Some of the products include AMD Radeon instinct MI50, AMD Instinct MI100, while for tensorflow same products can be used.

There are various models that can be used in AMD for image classifications. Some of them are as listed below –

Efficent b0 and b7

Resnet 101 and 50

Inceptive v3

For running a particular image container in PyTorch AMD, you will have to give a check on the operating system on which you have installed and the software and its version that you have installed in the process of running the containers of AMD. Some of the steps that need to be followed for running the containers are as given below –

A search of the tab named Tags and then hit into the container image release that is located inside it, which you are about to run.

You will have to paste the command you have copied by opening a command prompt in your system. At this step, the beginning of pulling the image of the container happens. Before you go for the next step, make sure that the pulling of the docker completes.

Now, the container image that is pulled should be run. For running the container, you will have to choose the mode of interactive or non-interactive as per necessity and scenario.

While running the command, the “-it” parameter stands for the interactive mode running.

The option “–rm” specifies that the container should be deleted after finishing.

The parameter “-v” is used for specifying the directory for mounting.

The absolute path to the file or directory of the host system, which we will need to access in the container, is specified by using the parameter local_dir.

The target directory’s absolute path is specified by using the container_dir parameter when you are present in the container.

xx is the version of the container.

When you want to run particular command inside the image, the command parameter should be specified.

Examples of PyTorch AMD def sampleEducbaExample(args, educbaModel, sampleEducbaExample_loader): educbaModel.eval() corectionPrecision = 0 cumulativeCount = 0 with torch.no_grad(): for data, target in sampleEducbaExample_loader: achievedOutput = educbaModel(data) predictedValue = achievedOutput.argmax(dim=1) corectionPrecision += predictedValue.eq(target.view_as(predictedValue)).sum() cumulativeCount += args.sampleEducbaExample_batch_size cumulativeCorrections = corectionPrecision.copy().get().float_precision().long().item() print('Test set: Accuracy: {}/{} ({:.0f}%)'.format( cumulativeCorrections, cumulativeCount, 100. * cumulativeCorrections / cumulativeCount))

The output of the execution of the above program gives the following result on the console panel –

Here, we have carried out the predictions in a secure manner from end to end. Both server and client are completely unaware. The server has no idea about the output of classification and input of data, and the client is not aware of the server’s model weights.

Conclusion

We can use PyTorch AMD to improve the user’s data protection and secure machine learning. The docker container of PyTorch 3.6 internally provides AMD support.

Recommended Articles

This is a guide to PyTorch AMD. Here we discuss What is PyTorch AMD, how to use PyTorch AMD, image classification models in AMD. You may also have a look at the following articles to learn more –

Update the detailed information about How To Use Excel Vba Or Function With Examples? on the Cattuongwedding.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!