Create custom functions in Excel

A fast and secure browser thats designed for Windows 10

Although Excel includes a multitude of built-in worksheet functions, chances are it doesnt have a function for every type of calculation you perform. The designers of Excel couldnt possibly anticipate every users calculation needs. Instead, Excel provides you with the ability to create custom functions, which are explained in this article.

Custom functions, like macros, use theVisual Basic for Applications (VBA)programming language. They differ from macros in two significant ways. First, they useFunctionprocedures instead ofSubprocedures. That is, they start with aFunctionstatement instead of aSubstatement and end withEnd Functioninstead ofEnd Sub. Second, they perform calculations instead of taking actions. Certain kinds of statements, such as statements that select and format ranges, are excluded from custom functions. In this article, youll learn how to create and use custom functions. To create functions and macros, you work with theVisual Basic Editor (VBE), which opens in a new window separate from Excel.

Suppose your company offers a quantity discount of 10 percent on the sale of a product, provided the order is for more than 100 units. In the following paragraphs, well demonstrate a function to calculate this discount.

The example below shows an order form that lists each item, quantity, price, discount (if any), and the resulting extended price.

To create a custom DISCOUNT function in this workbook, follow these steps:

PressAlt+F11to open the Visual Basic Editor (on the Mac, pressFN+ALT+F11), and then clickInsertModule. A new module window appears on the right-hand side of the Visual Basic Editor.

Copy and paste the following code to the new module.

DISCOUNT = Application.Round(Discount, 2)

Note:To make your code more readable, you can use theTabkey to indent lines. The indentation is for your benefit only, and is optional, as the code will run with or without it. After you type an indented line, the Visual Basic Editor assumes your next line will be similarly indented. To move out (that is, to the left) one tab character, pressShift+Tab.

Now youre ready to use the new DISCOUNT function. Close the Visual Basic Editor, select cell G7, and type the following:

Excel calculates the 10 percent discount on 200 units at $47.50 per unit and returns $950.00.

In the first line of your VBA code, Function DISCOUNT(quantity, price), you indicated that the DISCOUNT function requires two arguments,quantityandprice. When you call the function in a worksheet cell, you must include those two arguments. In the formula =DISCOUNT(D7,E7), D7 is thequantityargument, and E7 is thepriceargument. Now you can copy the DISCOUNT formula to G8:G13 to get the results shown below.

Lets consider how Excel interprets this function procedure. When you pressEnter, Excel looks for the nameDISCOUNTin the current workbook and finds that it is a custom function in a VBA module. The argument names enclosed in parentheses,quantityandprice, are placeholders for the values on which the calculation of the discount is based.

The If statement in the following block of code examines thequantityargument and determines whether the number of items sold is greater than or equal to 100:

If the number of items sold is greater than or equal to 100, VBA executes the following statement, which multiplies thequantityvalue by thepricevalue and then multiplies the result by 0.1:

The result is stored as the variableDiscount. A VBA statement that stores a value in a variable is called anassignmentstatement, because it evaluates the expression on the right side of the equal sign and assigns the result to the variable name on the left. Because the variableDiscounthas the same name as the function procedure, the value stored in the variable is returned to the worksheet formula that called the DISCOUNT function.

Ifquantityis less than 100, VBA executes the following statement:

Finally, the following statement rounds the value assigned to theDiscountvariable to two decimal places:

Discount = Application.Round(Discount, 2)

VBA has no ROUND function, but Excel does. Therefore, to use ROUND in this statement, you tell VBA to look for the Round method (function) in the Application object (Excel). You do that by adding the wordApplicationbefore the word Round. Use this syntax whenever you need to access an Excel function from a VBA module.

A custom function must start with a Function statement and end with an End Function statement. In addition to the function name, the Function statement usually specifies one or more arguments. You can, however, create a function with no arguments. Excel includes several built-in functionsRAND and NOW, for examplethat dont use arguments.

Following the Function statement, a function procedure includes one or more VBA statements that make decisions and perform calculations using the arguments passed to the function. Finally, somewhere in the function procedure, you must include a statement that assigns a value to a variable with the same name as the function. This value is returned to the formula that calls the function.

The number of VBA keywords you can use in custom functions is smaller than the number you can use in macros. Custom functions are not allowed to do anything other than return a value to a formula in a worksheet, or to an expression used in another VBA macro or function. For example, custom functions cannot resize windows, edit a formula in a cell, or change the font, color, or pattern options for the text in a cell. If you include action code of this kind in a function procedure, the function returns the VALUE! error.

The one action a function procedure can do (apart from performing calculations) is display a dialog box. You can use anInputBoxstatement in a custom function as a means of getting input from the user executing the function. You can use aMsgBoxstatement as a means of conveying information to the user. You can also use custom dialog boxes, orUserForms, but thats a subject beyond the scope of this introduction.

Even simple macros and custom functions can be difficult to read. You can make them easier to understand by typing explanatory text in the form of comments. You add comments by preceding the explanatory text with an apostrophe. For example, the following example shows the DISCOUNT function with comments. Adding comments like these makes it easier for you or others to maintain your VBA code as time passes. If you need to make a change to the code in the future, youll have an easier time understanding what you did originally.

An apostrophe tells Excel to ignore everything to the right on the same line, so you can create comments either on lines by themselves or on the right side of lines containing VBA code. You might begin a relatively long block of code with a comment that explains its overall purpose and then use inline comments to document individual statements.

Another way to document your macros and custom functions is to give them descriptive names. For example, rather than name a macroLabels, you could name itMonthLabelsto describe more specifically the purpose the macro serves. Using descriptive names for macros and custom functions is especially helpful when youve created many procedures, particularly if you create procedures that have similar but not identical purposes.

How you document your macros and custom functions is a matter of personal preference. Whats important is to adopt some method of documentation, and use it consistently.

To use a custom function, the workbook containing the module in which you created the function must be open. If that workbook is not open, you get a NAME? error when you try to use the function. If you reference the function in a different workbook, you must precede the function name with the name of the workbook in which the function resides. For example, if you create a function called DISCOUNT in a workbook called Personal.xlsb and you call that function from another workbook, you must type=personal.xlsb!discount(), not simply=discount().

You can save yourself some keystrokes (and possible typing errors) by selecting your custom functions from the Insert Function dialog box. Your custom functions appear in the User Defined category:

An easier way to make your custom functions available at all times is to store them in a separate workbook and then save that workbook as an add-in. You can then make the add-in available whenever you run Excel. Heres how to do this:

After you have created the functions you need, clickFileSave As.

In Excel 2007, click theMicrosoft Office Button, and clickSave As

In theSave Asdialog box, open theSave As Typedrop-down list, and selectExcel Add-In. Save the workbook under a recognizable name, such asMyFunctions, in theAddInsfolder. TheSave Asdialog box will propose that folder, so all you need to do is accept the default location.

After you have saved the workbook, clickFileExcel Options.

In Excel 2007, click theMicrosoft Office Button, and clickExcel Options.

In theExcel Optionsdialog box, click theAdd-Inscategory.

In theManagedrop-down list, selectExcel Add-Ins. Then click theGobutton.

In theAdd-Insdialog box, select the check box beside the name you used to save your workbook, as shown below.

After you have created the functions you need, clickFileSave As.

In theSave Asdialog box, open theSave As Typedrop-down list, and selectExcel Add-In. Save the workbook under a recognizable name, such asMyFunctions.

After you have saved the workbook, clickToolsExcel Add-Ins.

In theAdd-Insdialog box, select the Browse button to find your add-in, clickOpen, then check the box beside your Add-In in theAdd-Ins Availablebox.

After you follow these steps, your custom functions will be available each time you run Excel. If you want to add to your function library, return to the Visual Basic Editor. If you look in the Visual Basic Editor Project Explorer under a VBAProject heading, you will see a module named after your add-in file. Your add-in will have the extension .xlam.

Double-clicking that module in the Project Explorer causes the Visual Basic Editor to display your function code. To add a new function, position your insertion point after the End Function statement that terminates the last function in the Code window, and begin typing. You can create as many functions as you need in this manner, and they will always be available in the User Defined category in theInsert Functiondialog box.

This content was originally authored by Mark Dodge and Craig Stinson as part of their bookMicrosoft Office Excel 2007 Inside Out. It has since been updated to apply to newer versions of Excel as well.

You can always ask an expert in theExcel Tech Community, get support in theAnswers community, or suggest a new feature or improvement onExcel User Voice.

Supreme Courts same-sex wedding cake decision — a significant victory for freedom

On Monday, the U.S. Supreme Court ruled in favor of cake artist Jack Phillips, saying the Colorado Civil Rights Commission unjustly punished him when it ordered Jack to create a custom wedding cake celebrating a same-sex wedding. As the court said, [t]he neutral and respectful consideration to which Phillips was entitled was compromised here . The Civil Rights Commissions treatment of his case has some elements of a clear and impermissible hostility toward the sincere religious beliefs that motivated his objection.

By now, many Americans have heard of Colorados Jack Phillips; of his family business, Masterpiece Cakeshop; and of his decision not to design that custom wedding cake.

But some do not know the whole story. Jack has never refused to serve any person based on who they are or what they look like. Everyone is welcome in his shopeven the two men who sued him. In fact, he told those men that, even though he couldnt create a custom cake to celebrate a same-sex marriage, he would be happy to sell them anything else in his shop or design a cake for them for a different occasion.

Over the years, Jack has declined to create many custom cakes because of the messages they express. If youre looking for a ghoulish Halloween cake, a boozy bachelorette-themed dessert, or a cake celebrating a divorceMasterpiece Cakeshop isnt your place.

Thats because Jack has heart, convictions, and faithin addition to talents. He isnt a well-programmed robot but a human who believes things about God, about marriage, and about the world. Jack isnt confrontational about his beliefs, but he wants to use his talents to convey messages or celebrate events that he thinks are good, beautiful, and true.

The Supreme Court drew a line in the sand and protected the religious freedom of people like Jack. It said that religious hostility has no place in a diverse society like ours, whether the government is regulating art or anything else.

And that leads to an important point: While skill and heart are essential for all real art, its not true that all works involving creativity qualify as constitutionally protected expression. For that, the item must communicate a message. Thats surely true of Jacks wedding cakes, each of which is carefully sketched, designed, and hand-crafted to announce the couples union as a marriage and tell part of their story.

Yet if the Colorado Civil Rights Commission had its way, Jacks voice would have been silenced; his hands would have been tied. After the commissions decision, Jack was forced to give up designing the wedding cakes that he loves to create and lost 40 percent of his business and over half his employees.

You can disagree with Jacks decision or his convictions but still see the problem here: Artistic expression comes from the mind, the heart, and the soul. It is fueled by conviction and passion. The very concept of government-mandated art is itself a contradiction. As Leonardo da Vinci said, Where the spirit does not work with the hand, there is no art.

One ACLU lawyer has argued that the issue here isnt access to wedding cakes. Its the freedom to be a full participant in civic and economic life. Thats exactly right. The men who sued Jack got their cake and their wedding. They participated in civic life and didnt need Jack to be part of their celebration.

But if the commissions order stood, Jacks freedom to create based on his convictions would have been stripped away, his business decimated, and his beliefs banished from public life. The Supreme Court saw no justice in that. Those who believe that marriage is the union of a man and a woman shouldnt be ostracized, banished from society simply because of what they believe.

When Jack puts on his apron, he shouldnt lose his voice. When he opens his business, he shouldnt lose his freedom. Batter, frosting, and fondant, in the hands of a skilled artist, do tell storiesthey do express messages.

On Monday, the Supreme Court drew a line in the sand and protected the religious freedom of people like Jack. It said that religious hostility has no place in a diverse society like ours, whether the government is regulating art or anything else. Its a significant victory. For freedom.

Kristen Waggoner is senior vice presidentofAllianceDefending Freedoms U.S. legaldivision and argued on behalf of Jack Phillips and Masterpiece Cakeshop beforethe U.S. Supreme Court.

Bill Clinton thinks HES the victim in the age of MeToo — Will he ever grow up?

Trump has the power to pardon himself, but that could get him impeached

Newt Gingrich: The red wave is growing

Judge Andrew Napolitano: Can Trump shoot James Comey?

How to Create Custom Excel Functions

How to Create Custom Excel Functions

Manually Editing Data Connections in Excel

How to Calculate Revenue in Your Financial Model

Discounting Cash Flows and Valuation in Your Financial Model

Building Scenarios in Your Financial Model

Despite all the functions provided by Excel, you may need one that you just dont see offered. Excel lets you create your own functions by using VBA programming code; your functions show up in the Insert Function dialog box.

Writing VBA code is not for everyone. But nonetheless, here is a short-and-sweet example. If you can conquer this, you may want to find out more about programming VBA. Who knows maybe one day youll be churning out sophisticated functions of your own! Make sure you are working in a macro-enabled workbook (one of the Excel file types).

Follow along to create custom functions:

This gets you to the Visual Basic Editor, where VBA is written.

You can also click the Visual Basic button on the Developer tab of the Ribbon. The Developer tab is visible only if the Developer checkbox is checked on the Customize Ribbon tab of the Excel Options dialog box.

Choose InsertModule in the editor.

You have an empty code module sitting in front of you. Now its time to create your very own function!

Type this programming code, shown in the following figure:

Macros and VBA programming can be saved only in a macro-enabled workbook.

After you type the first line and press Enter, the last one appears automatically. This example function adds two numbers, and the word Public lists the function in the Insert Function dialog box. You may have to find the Excel workbook on the Windows taskbar because the Visual Basic Editor runs as a separate program. Or press Alt+ F11 to toggle back to the Workbook.

Click the Insert Function button on the Formulas tab to display the Insert Function dialog box.

The Function Arguments dialog box opens, ready to receive the arguments. Isnt this incredible? Its as though you are creating an extension to Excel, and in essence, you are.

This is a very basic example of what you can do by writing your own function. The possibilities are endless, but of course, you need to know how to program VBA.

Macro-enabled workbooks have the file extension.xlsm.

Creating Custom Estimators

This document introduces custom Estimators. In particular, this document demonstrates how to create a customEstimatorthat mimics the behavior of the pre-made Estimatorin solving the Iris problem. See thePre-Made Estimators chapterfor details on the Iris problem.

To download and access the example code invoke the following two commands:

In this document we will be looking atcustom_estimator.py. You can run it with the following command:

If you are feeling impatient, feel free to compare and contrastcustom_estimator.pywithpremade_estimator.py. (which is in the same directory).

As the following figure shows, pre-made Estimators are subclasses of thetf.estimator.Estimatorbase class, while custom Estimators are an instance of tf.estimator.Estimator:

Pre-made Estimators are fully baked. Sometimes though, you need more control over an Estimators behavior. Thats where custom Estimators come in. You can create a custom Estimator to do just about anything. If you want hidden layers connected in some unusual fashion, write a custom Estimator. If you want to calculate a uniquemetricfor your model, write a custom Estimator. Basically, if you want an Estimator optimized for your specific problem, write a custom Estimator.

A model function (ormodel_fn) implements the ML algorithm. The only difference between working with pre-made Estimators and custom Estimators is:

Your model function could implement a wide range of algorithms, defining all sorts of hidden layers and metrics. Like input functions, all model functions must accept a standard group of input parameters and return a standard group of output values. Just as input functions can leverage the Dataset API, model functions can leverage the Layers API and the Metrics API.

Lets see how to solve the Iris problem with a custom Estimator. A quick reminder–heres the organization of the Iris model that were trying to mimic:

Our custom Estimator implementation uses the same input function as ourpre-made Estimator implementation, fromiris_data.py. Namely:

def train_input_fn(features, labels, batch_size): An input function for training Convert the inputs to a Dataset. dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels)) Shuffle, repeat, and batch the examples. dataset = dataset.shuffle(1000).repeat().batch(batch_size) Return the read end of the pipeline. return dataset.make_one_shot_iterator().get_next()

This input function builds an input pipeline that yields batches of(features, labels)pairs, wherefeaturesis a dictionary features.

As detailed in thePremade EstimatorsandFeature Columnschapters, you must define your models feature columns to specify how the model should use each feature. Whether working with pre-made Estimators or custom Estimators, you define feature columns in the same fashion.

The following code creates a simplenumeric_columnfor each input feature, indicating that the value of the input feature should be used directly as an input to the model:

Feature columns describe how to use the input. my_feature_columns = [] for key in train_x.keys(): my_feature_columns.append(tf.feature_column.numeric_column(key=key))

The model function well use has the following call signature:

def my_model_fn( features, This is batch_features from input_fn labels, This is batch_labels from input_fn mode, An instance of tf.estimator.ModeKeys params): Additional configuration

The first two arguments are the batches of features and labels returned from the input function; that is,featuresandlabelsare the handles to the data your model will use. Themodeargument indicates whether the caller is requesting training, predicting, or evaluation.

The caller may passparamsto an Estimators constructor. Anyparamspassed to the constructor are in turn passed on to themodel_fn. Incustom_estimator.pythe following lines create the estimator and set the params to configure the model. This configuration step is similar to how we configured thetf.estimator.DNNClassifierinPremade Estimators.

classifier = tf.estimator.Estimator( model_fn=my_model, params= feature_columns: my_feature_columns, Two hidden layers of 10 nodes each. hidden_units: [10, 10], The model must choose between 3 classes. n_classes: 3, )

To implement a typical model function, you must do the following:

The basic deep neural network model must define the following three sections:

The first line of themodel_fncallsto convert the feature dictionary andfeature_columnsinto input for your model, as follows:

The preceding line applies the transformations defined by your feature columns, creating the models input layer.

If you are creating a deep neural network, you must define one or more hidden layers. The Layers API provides a rich set of functions to define all types of hidden layers, including convolutional, pooling, and dropout layers. For Iris, were simply going to callto create hidden layers, with dimensions defined byparams[hidden_layers]. In adenselayer each node is connected to every node in the preceding layer. Heres the relevant code:

Build the hidden layers, sized according to the hidden_units param. for units in params[hidden_units]: net = tf.layers.dense(net, units=units, activation=tf.nn.relu)

parameter defines the number of output neurons in a given layer.

parameter defines theactivation functionReluin this case.

The variablenethere signifies the current top layer of the network. During the first iteration,netsignifies the input layer. On each loop iterationtf.layers.densecreates a new layer, which takes the previous layers output as its input, using the variablenet.

After creating two hidden layers, our network looks as follows. For simplicity, the figure does not show all the units in each layer.

Note thatprovides many additional capabilities, including the ability to set a multitude of regularization parameters. For the sake of simplicity, though, were going to simply accept the default values of the other parameters.

Well define the output layer by callingtf.layers.denseyet again, this time without an activation function:

Here,netsignifies the final hidden layer. Therefore, the full set of layers is now connected as follows:

When defining an output layer, theunitsparameter specifies the number of outputs. So, by settingunitstoparams[n_classes], the model produces one output value per class. Each element of the output vector will contain the score, or logit, calculated for the associated class of Iris: Setosa, Versicolor, or Virginica, respectively.

Later on, these logits will be transformed into probabilities by thetf.nn.softmaxfunction.

The final step in creating a model function is to write branching code that implements prediction, evaluation, and training.

The model function gets invoked whenever someone calls the Estimatorstrain,evaluate, orpredictmethods. Recall that the signature for the model function looks like this:

def my_model_fn( features, This is batch_features from input_fn labels, This is batch_labels from input_fn mode, An instance of tf.estimator.ModeKeys, see below params): Additional configuration

Focus on that third argument, mode. As the following table shows, when someone callstrain,evaluate, orpredict, the Estimator framework invokes your model function with the mode parameter set as follows:

For example, suppose you instantiate a custom Estimator to generate an object namedclassifier. Then, you make the following call:

The Estimator framework then calls your model function with mode set toModeKeys.TRAIN.

Your model function must provide code to handle all three of the mode values. For each mode value, your code must return an instance oftf.estimator.EstimatorSpec, which contains the information the caller requires. Lets examine each mode.

When the Estimatorspredictmethod is called, themodel_fnreceivesmode = ModeKeys.PREDICT. In this case, the model function must return atf.estimator.EstimatorSpeccontaining the prediction.

The model must have been trained prior to making a prediction. The trained model is stored on disk in themodel_dirdirectory established when you instantiated the Estimator.

The code to generate the prediction for this model looks as follows:

Compute predictions. predicted_classes = tf.argmax(logits, 1) if mode == tf.estimator.ModeKeys.PREDICT: predictions = class_ids: predicted_classes[:, tf.newaxis], probabilities: tf.nn.softmax(logits), logits: logits, return tf.estimator.EstimatorSpec(mode, predictions=predictions)

The prediction dictionary contains everything that your model returns when run in prediction mode.

Thepredictionsholds the following three key/value pairs:

holds the class id (0, 1, or 2) representing the models prediction of the most likely species for this example.

holds the three probabilities (in this example, 0.02, 0.95, and 0.03)

holds the raw logit values (in this example, -1.3, 2.6, and -0.9)

We return that dictionary to the caller via thepredictionsparameter of thetf.estimator.EstimatorSpec. The Estimatorspredictmethod will yield these dictionaries.

For bothtrainingandevaluationwe need to calculate the models loss. This is theobjectivethat will be optimized.

We can calculate the loss by callingtf.losses.sparse_softmax_cross_entropy. The value returned by this function will be lowest, approximately 0, probability of the correct class (at indexlabel) is near 1.0. The loss value returned is progressively larger as the probability of the correct class decreases.

This function returns the average over the whole batch.

When the Estimatorsevaluatemethod is called, themodel_fnreceivesmode = ModeKeys.EVAL. In this case, the model function must return atf.estimator.EstimatorSpeccontaining the models loss and optionally one or more metrics.

Although returning metrics is optional, most custom Estimators do return at least one metric. TensorFlow provides a Metrics moduleto calculate common metrics. For brevitys sake, well only return accuracy. Thetf.metrics.accuracyfunction compares our predictions against the true values, that is, against the labels provided by the input function. Thetf.metrics.accuracyfunction requires the labels and predictions to have the same shape. Heres the call totf.metrics.accuracy:

TheEstimatorSpecreturned for evaluation typically contains the following information:

So, well create a dictionary containing our sole metric. If we had calculated other metrics, we would have added them as additional key/value pairs to that same dictionary. Then, well pass that dictionary in theeval_metric_opsargument oftf.estimator.EstimatorSpec. Heres the code:

metrics = accuracy: accuracy tf.summary.scalar(accuracy, accuracy[1]) if mode == tf.estimator.ModeKeys.EVAL: return tf.estimator.EstimatorSpec( mode, loss=loss, eval_metric_ops=metrics)

Thetf.summary.scalarwill make accuracy available to TensorBoard in bothTRAINandEVALmodes. (More on this later).

When the Estimatorstrainmethod is called, themodel_fnis called withmode = ModeKeys.TRAIN. In this case, the model function must return anEstimatorSpecthat contains the loss and a training operation.

Building the training operation will require an optimizer. We will usetf.train.AdagradOptimizerbecause were mimicking theDNNClassifier, which also usesAdagradby default. Thetf.trainpackage provides many other optimizersfeel free to experiment with them.

Here is the code that builds the optimizer:

Next, we build the training operation using the optimizersminimizemethod on the loss we calculated earlier.

Theminimizemethod also takes aglobal_stepparameter. TensorFlow uses this parameter to count the number of training steps that have been processed (to know when to end a training run). Furthermore, theglobal_stepis essential for TensorBoard graphs to work correctly. Simply calltf.train.get_global_stepand pass the result to theglobal_stepargument ofminimize.

Heres the code to train the model:

TheEstimatorSpecreturned for training must have the following fields set:

Heres our code to callEstimatorSpec:

Instantiate the custom Estimator through the Estimator base class as follows:

Build 2 hidden layer DNN with 10, 10 units respectively. classifier = tf.estimator.Estimator( model_fn=my_model, params= feature_columns: my_feature_columns, Two hidden layers of 10 nodes each. hidden_units: [10, 10], The model must choose between 3 classes. n_classes: 3, )

Here theparamsdictionary serves the same purpose as the key-word arguments ofDNNClassifier; that is, theparamsdictionary lets you configure your Estimator without modifying the code in themodel_fn.

The rest of the code to train, evaluate, and generate predictions using our Estimator is the same as in thePremade Estimatorschapter. For example, the following line will train the model:

You can view training results for your custom Estimator in TensorBoard. To see this reporting, start TensorBoard from your command line as follows:

Then, open TensorBoard by browsing to:

All the pre-made Estimators automatically log a lot of information to TensorBoard. With custom Estimators, however, TensorBoard only provides one default log (a graph of the loss) plus the information you explicitly tell TensorBoard to log. For the custom Estimator you just created, TensorBoard generates the following:

In brief, heres what the three graphs tell you:

global_step/sec: A performance indicator showing how many batches (gradient updates) we processed per second as the model trains.

accuracy: The accuracy is recorded by the following two lines:

These tensorboard graphs are one of the main reasons its important to pass aglobal_stepto your optimizersminimizemethod. The model cant record the x-coordinate for these graphs without it.

Note the following in themy_accuracyandlossgraphs:

During training, summaries (the orange line) are recorded periodically as batches are processed, which is why it becomes a graph spanning x-axis range.

By contrast, evaluation produces only a single point on the graph for each call toevaluate. This point contains the average over the entire evaluation call. This has no width on the graph as it is evaluated entirely from the model state at a particular training step (from a single checkpoint).

As suggested in the following figure, you may see and also selectively disable/enable the reporting using the controls on the left side.

Although pre-made Estimators can be an effective way to quickly create new models, you will often need the additional flexibility that custom Estimators provide. Fortunately, pre-made and custom Estimators follow the same programming model. The only practical difference is that you must write a model function for custom Estimators; everything else is the same.

For more details, be sure to check out:

Theofficial TensorFlow implementation of MNIST, which uses a custom estimator.

The TensorFlowofficial models repository, which contains more curated examples using custom estimators.

ThisTensorBoard video, which introduces TensorBoard.

TheLow Level Introduction, which demonstrates how to experiment directly with TensorFlows low level APIs, making debugging easier.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 3.0 License, and code samples are licensed under theApache 2.0 License. For details, see ourSite Policies. Java is a registered trademark of Oracle and/or its affiliates.

Create custom roles

If thebuilt-in rolesdont meet your specific access needs, you can create your own custom roles. Just like built-in roles, you can assign custom roles to users, groups, and service principals at subscription, resource group, and resource scopes. Custom roles are stored in an Azure Active Directory (Azure AD) tenant and can be shared across subscriptions. Each tenant can have up to 2000 custom roles. Custom roles can be created using Azure PowerShell, Azure CLI, or the REST API.

This article describes an example of how to get started creating custom roles using PowerShell and Azure CLI.

To create a custom role, you can start with a built-in role, edit it, and then create a new role. For this example, the built-inReaderrole is customized to create a custom role named Reader support tickets access level. It allows the user to view everything in the subscription and also open support requests.

The only two built-in roles that allow a user to open support requests areOwnerandContributor. For a user to be able to open support requests, he must be assigned a role at the subscription scope, because all support requests are created based on an Azure subscription.

In PowerShell, use theGet-AzureRmRoleDefinitioncommand to export theReaderrole in JSON format.

The following shows the JSON output for theReaderrole. A typical role is composed of three main sections,Actions,NotActions, andAssignableScopes. TheActionssection lists all the permitted operations for the role. To exclude operations fromActions, you add them toNotActions. The effective permissions is computed by subtracting theNotActionsoperations from theActionsoperations.

Name: Reader, Id: acdd72a7-3385-48ef-bd42-f606fba81ae7, IsCustom: false, Description: Lets you view everything, but not make any changes., Actions: [ */read ], NotActions: [ ], AssignableScopes: [ / ]

Next, you edit the JSON output to create your custom role. In this case, to create support tickets, theMicrosoft.Support/*operation must be added. Each operation is made available from a resource provider. To get a list of the operations for a resource provider, you can use theGet-AzureRmProviderOperationcommand or seeAzure Resource Manager resource provider operations.

Its mandatory that the role contains the explicit subscription IDs where it is used. The subscription IDs are listed underAssignableScopes, otherwise you will not be allowed to import the role into your subscription.

Finally, you must set theIsCustomproperty totrueto specify that this is a custom role.

Name: Reader support tickets access level, IsCustom: true, Description: View everything in the subscription and also open support requests., Actions: [ */read, Microsoft.Support/* ], NotActions: [ ], AssignableScopes: [ /subscriptions/1111-1111-1 ]

To create the new custom role, you use theNew-AzureRmRoleDefinitioncommand and provide the updated JSON role definition file.

After runningNew-AzureRmRoleDefinition, the new custom role is available in the Azure portal and can be assigned to users.

Users with this custom role can create new support requests.

Users with this custom role cannot perform other actions, such as create VMs or create resource groups.

The steps to create a custom role using Azure CLI are similar to using PowerShell, except that the JSON output is different.

For this example, you can start with the built-inReaderrole. To list the actions of theReaderrole, use theaz role definition listcommand.

az role definition list –name Reader –output json

[ additionalProperties: , assignableScopes: [ / ], description: Lets you view everything, but not make any changes., id: /subscriptions/1111-1111-1/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7, name: acdd72a7-3385-48ef-bd42-f606fba81ae7, permissions: [ actions: [ */read ], additionalProperties: , notActions: [], ], roleName: Reader, roleType: BuiltInRole, type: Microsoft.Authorization/roleDefinitions ]

Create a JSON file with the following format. TheMicrosoft.Support/*operation has been added in theActionssections so that this user can open support requests while continuing to be a reader. You must add the subscription ID where this role will be used in theAssignableScopessection.

Name: Reader support tickets access level, IsCustom: true, Description: View everything in the subscription and also open support requests., Actions: [ */read, Microsoft.Support/* ], NotActions: [ ], AssignableScopes: [ /subscriptions/1111-1111-1 ]

To create the new custom role, use theaz role definition createcommand.

The new custom role is now available in the Azure portal and the process to use this role is the same as in the previous PowerShell section.

Manage role-based access control with AzurePowerShell

Manage role-based access control with Azure CLI

Manage role-based access control with the REST API

Wed love to hear your thoughts. Choose the type youd like to provide:

Our new feedback system is built on GitHub Issues. Read about this change inour blog post.

How to Create a Custom Email Address

Creating a custom email address is an important step in taking your business from a side hobby to a serious business. Using a custom email such as instead of changes the way your correspondents perceive you and your business.

Luckily for you, its pretty easy to create an email address. In this guide we will go over the different options for creating a custom email, and then show you step by step how to set it up using your web hosting provider.

There are two main options for creating a custom email address:

The least expensive way to get a custom email address is by setting it up through a web hosting company. For as low as $2.95 per month, you can get a business email addressplusa website with hosting fromBluehost.

While this option allows you to create a website at no extra cost, were going to focus on how to create a free business email address in this guide. View this guide to learnhow to make a WordPress websitewith Bluehost.

If you already have a website, see if the company that hosts your website includes free business email with your plan. Many hosting providers do, includingBluehostHostGatorandGoDaddy.

If you dont have a website and dont want one, then you can create a custom email address usingGoogle G Suite. This option goes for $5 per month.

In this guide, we will go over the first option, showing you how to create an email address through your hosting service.

Now, well go through the process of how to set up your free email address using a web host provider. After we show you how to setup your email, we will point you to where you can go to learn how to set up your website.

Well useBluehostto show you the process, but the steps will be similar for most web hosting companies. For example, if you currently useGoDaddyorHostGatorto host your website, then many steps in this article, such as linking your business email account with Gmail, will be almost identical.

Choosing a domain name is a very important part of creating your custom email. This is what will show after the @ symbol in your email address. Not to mention, it will be the URL for your website.

If you need help brainstorming to find your perfect domain name, check out our25 tips from the pros. To see if the domain name you want is available, check in the box below.

Once youve nailed down your domain name, youre ready to sign up forBluehost. Enter the domain name, fill out your contact information, and choose your plan.

At the moment, they are offering prices as low as $2.95 per month if you sign up for 36 months. We suggest going with this option, since you can cancel at any time andreceive a prorated refundbased on how long you have used the service.

Once youve purchased your plan, you will be directed toBluehosts dashboard. If you scroll down youll see the email section. Click on the email manager.

Hit create an email account and enter the text you want to come before your domain name in your email address. You will also need to choose a password.

When choosing the name that will display before the @ symbol, youll want to have a standard format for all of your employees. View our explanation on this plus moretips to creating your email addresshere.

When youve set up the name and password, hit create. Repeat this step for all of your employees.

If you are creating the custom email address simply as a way to look more professional on your business card or website, you can set up email forwarding. This way, you can still use your existing email account by having all emails sent to your professional email address forwarded to your current account.

The drawback with doing this is that if you respond through your current email, then you will not be able to change your From address to your business email. In other words, your email will look like it is coming from your current account, not your business email.

The good news is that if you are currently using Gmail, you can connect it with your Bluehost email. This will enable you to use your business email as your From address, as well as keep all of your inboxes organized in the same place. Well show you how to do this in the next step.

You can use Bluehosts inbox, but the interface is not very user friendly. Instead, we suggest connecting your Bluehost email with your Gmail or Outlook account in order to have a better experience navigating your inbox.

To connect your newBluehostbusiness email with an Outlook account, you can follow one of the guides below. The steps will vary slightly depending on which edition of Outlook youre using, so choose the one that corresponds to your current account.

If you have a Gmail account, you will probably want to unify your work and personal emails through Gmail. That way, you wont have to worry about logging into multiple accounts. This is time consuming, and theres a chance youll miss an important email that was sent to an account you dont use as often.

To get started, youll need to first login to your Gmail account. If you dont already have one, you can quickly create one for freehere.

Now, click on the gear in the top right corner and hit settings.

Navigate to the Accounts and Import tab at the top and then click Add a mail account.

This will open a new window where you can enter theBluehostemail you just created. Enter your full business email address and Bluehost password in the window.

IMPORTANT be sure to enter your FULL business email address in the Username field, including your domain.

You have now made it so that all emails sent to yourBluehostemail address will land in your Gmail folder.

You will want to also change it so that your outgoing messages are being sent from your new custom email address.

On the following screen, Bluehost will ask if you want to set this up.

Youll have to enter your full email address and password again. Gmail will send you a verification code to your Bluehost account.

Head back into yourBluehostaccount. Select Email Manager and click View Inbox. You should see an email from Google with your verification code. Copy/paste this code, and enter it back into Gmail.

Once youve combined your accounts, youll be able to navigate between your professional and personal email addresses. Just choose which From address you want to use while composing your email.

Thats it! Wait a little while, then send a message to your new email address. You should see it appear in your Gmail account, and have the ability to respond using your new address.

Now that you were able to create an email address, its time to create your website! View ourstep by step guide, and youll be filling in pages on your own website within 30 minutes.

Maggie Aland is a staff writer for Fit Small Business and editor of the Marketing and Reviews sections. She writes on a variety of marketing topics, ranging from newspaper ads to how to market your business on Facebook. Before joining Fit Small Business, Maggie worked as a marketing associate at a niche publishing company. There she was responsible for determining the marketing plan and keeping up with the budget of 10+ B2B products. Her experience includes email, direct mail, social media, events, and more. When not editing or writing, you can find Maggie looking for the best brunch spots in NYC.

Top 25 Real Estate Hashtags ( How to Use Them)

California Paid Sick Leave Law: How it Works Employer FAQs

Disclaimer:Reviews on are the product of independent research by our writers, researchers, and editorial team. User reviews and comments are contributions from independent users not affiliated with ms editorial team. Banks, issuers, credit card companies, and other product & service providers are not responsible for any content posted on FitSmallBusiness.com. As such, they do not endorse or guarantee any posted comments or reviews.Cancel replyCommentReview SourceOrganicFitSmallBusiness invited user to leave a review and offered a nominal gift card as a thank you.Vendor invited user to leave a review.How likely are you to recommend this product to a friend or colleague?- Select -0 – Not Likely12345678910 – Very LikelyWhat does the company do well?What does the company not do well?What about the company do you wish you had known before purchasing?Upload a screenshot…

To be marked as a Verified User, upload a screenshot of you logged into the platform. The image will be reviewed by our team andwill notbe posted publicly.

Copyright © 2018 FitSmallBusiness. All Right Reserved.Privacy Policy.

Disclaimer:We spend hours researching and writing our articles and strive to provide accurate, up-to-date content. However, our research is meant to aid your own, and we are not acting as licensed professionals. We recommend that you consult with your own lawyer, accountant, or other licensed professional for relevant business decisions.Click here to see our full disclaimer.

Product or company names, logos, and trademarks referred to on this site belong to their respective owners.

How to Create Custom HTML Elements

Lego blocks photo by Kenny Louie / Flickr

An exciting feature of the HTML specification thats been getting a bit of hype recently is custom HTML elements. These allow you to create your own HTML elements along with their own JavaScript API. This can be useful when building interfaces with components that are reused throughout an application.

Free trial on Treehouse:Do you want to learn more about HTML and front-end programming?Click here to try a free trial on Treehouse.

In this blog post youre going to learn how to create your own HTML elements and define a JavaScript API for them.

Thedocument.registerElement()method is used to create a custom HTML element. This should be passed as the name of your custom element along with an (optional) object that defines the API.

In the following example we simply create a new HTML element calledx-treehouseand then add it to the page.

This would add the following HTML to the end of thebodyelement:

The name of your custom elementmustcontain a dash (-) so that the browsers parser can determine between standard and custom HTML elements. This also means that you wont encounter problems if a new HTML element is introduced that uses the same name as your custom element.

You can define a JavaScript API for your custom element that consists of a number of methods and properties. To do this, start by creating a new JavaScript object. This can be done using theObject.create()method. PassingHTMLElement.prototypeto this method will create an object with the standard set of methods and properties available to HTML elements.

You can then define your custom methods on this new object, as shown below.

To define a property for your custom element you can use theObject.defineProperty()method. The first parameter should be your prototype object; the second is the name of the property; and the third should be an object describing the behaviour of that property. This is where you can set a default value as well as specify whether the property is writable or read-only.

Once youve defined the API for your custom element, you need to calldocument.registerElement(). Use the name of your custom element as the first parameter, and then pass in an object with a property namedprototype. The value of this property should be set to the prototype object you created earlier.

Once youve registered your custom element, you can create a new instance of the element and add it to the page.

The methods and properties you defined earlier can be accessed just as you would on any other HTML element.

As well as creating your own custom elements, you can also use theregisterElement()method to extend the functionality of existing HTML elements. Lets extend theimgelement to create a variation for displaying thumbnail images.

You start by creating a prototype object as we did before. This time, however, you want to copy the prototype object of the element you are extending. In this case, that will be theHTMLImageElement.

Next you define a function for thecreatedCallback, which is fired when the element is created. (More on callbacks is in the next section.) Here we can set the width and height of the image.

You can also define custom methods and properties as before.

When extending an existing element, you need to add theextendsproperty to your options object in the call todocument.registerElement(). This property should be set to the name of the element you are extending.

To use your custom element, you can now specify anisattribute on the element that you have extended. Setting the value of this attribute to the name of your custom element will tell the browser that thisimgelement should use the API defined forthumb-img.

There are a number of callbacks that you can listen for when creating and managing your custom elements.

Called when a custom element is created.

Called when a custom element is inserted into the DOM.

Called when a custom element is removed from the DOM.

attributeChangedCallback(attrName, oldValue, newValue)

Called when an attribute on a custom element changes.

You specify functions for these callbacks on the prototype object thats passed todocument.registerElement().

var XTreehouseProto = Object.create(HTMLElement.prototype); XTreehouseProto.createdCallback = function() XTreehouseProto.attachedCallback = function() XTreehouseProto.detachedCallback = function() XTreehouseProto.attributeChangedCallback = function(attrName, oldValue, newValue) var XTreehouse = document.registerElement(x-treehouse, prototype: XTreehouseProto );

The true power of custom elements becomes clear when you think about how they can be used alongsideShadow DOM. This makes it really easy to create reusable interface components.

Using custom elements and shadow DOM to create reusable product cards.

In this section were going to look at an example of how you can use custom elements and Shadow DOM to create an interface component for displaying products in a web store. The idea here is that a web developer can easily create new products by adding a single line of HTML to their markup. All of the information needed to display the product is contained withindata-attributes on the custom element.

Well start by create a new prototype object based off ofHTMLElement.prototype.

Next we need to set up a function forcreatedCallback. This is where we will create theimgandaelements that are responsible for displaying the product. Ill show you the code first and then walk you through it.

// Set up the element. XProductProto.createdCallback = function() // Create a Shadow Root var shadow = this.createShadowRoot(); // Create an img element and set its attributes. var img = document.createElement(img); img.alt = this.getAttribute(data-name); img.src= this.getAttribute(data-img); img.width = 150; img.height = 150; img.className = product-img; // Add the image to the Shadow Root. shadow.appendChild(img); // Add an event listener to the image. img.addEventListener(click, function(e) window.location = this.getAttribute(data-url); ); // Create a link to the product. var link = document.createElement(a); nerText = this.getAttribute(data-name); link.href= this.getAttribute(data-url); link.className = product-name; // Add the link to the Shadow Root. shadow.appendChild(link); ;

Here we start by creating a new Shadow Root. If youre not familiar with using the Shadow DOM, you might want to check out myprevious post. We then create animgelement and set itsalt,src,height, andwidthattributes using the information specified on thex-productelement.

Note: Inside the callback function,thisrefers to the custom element in your markup.

Next we add theimgelement to the shadow root and create a newaelement. Again we set the attributes on the element using information from thedata-attributes on the custom element. To finish up we add theaelement we just created to the shadow root.

Now we need to register the custom element. Calldocument.registerElement()passing inx-productas the element name, and specifying theXProductProtoobject as the prototype.

That concludes all the JavaScript code thats needed to get this demo working. Lets add a bit of CSS to style the product items.

x-product display: inline-block; float: left; margin: 0.5em; border-radius: 3 box-shadow: 0 1px 3px rgba(0,0,0,0.3); font-family: Helvetica, arial, sans-serif; -webkit-font-smoothing: antialiased; x-product::shadow .product-img cursor: pointer; background: FFF; margin: 0.5em; x-product::shadow .product-name display: block; text-align: center; text-decoration: none; color: 08C; border-top: 1px solid EEE; font-weight: bold; padding: 0.75em 0;

To display a product, we just need to add anx-productelement to the HTML markup. The product data is set using thedata-name,data-img, anddata-urlattributes. When the page loads, the browser will recognise these as custom elements and fire thecreatedCallbackevent for each of them.

x-product data-name=Ruby data-img= data-url= x-product data-name=JavaScript data-img= data-url= x-product data-name=Python data-img= data-url=

Thats it! Youve now created a demo application that uses custom elements and shadow DOM to display a series of products.

Check out the demo to see this in action.

Note:This demo requires Shadow DOM, which is only supported inChrome Canary.

Google Chrome (version 33+) and Opera are the only browsers with support for custom elements at the moment. However, there is a greatpolyfillavailable from thePolymerproject that will add support for custom elements to other browsers. Thex-tagspolyfill maintained by Mozilla is also very useful.

Download the Polymer CustomElements Polyfill

You can check to see if the users browser supports custom elements by looking for theregisterElement()method on thedocumentobject.

In this post youve learned how to create custom HTML elements for use within your web applications. Youve also seen how to use custom elements alongside other technologies like Shadow DOM to build rich front-end web applications.

Custom elements promise to give web developers the ability to extend the web platform to better meet their needs. Being part of the web components suite, custom elements also play nicely with other technologies such as Shadow DOM and HTML templates. Theres no doubt in my mind that the introduction of web components marks a huge leap forward in the development of front-end web applications. The more I learn about this suite of technologies, the more excited I get!

What do you think about custom elements? Are you planning to use them in your projects? Share your thoughts in the comments.

Whats up to every one, the contents existing at

this web site arre really remarkable for people experience, well, keep up

Hi , I am planning to use custom tag and to register with JS and have one question, if I will use my custom tag on page and load the related JS at the end of page this will going to break my page. why I am asking this as this cust-tag will be used as a component and I dont have control on target page how they are loading the JS , so do we have any mechanism to parse the only after JS loaded so it work irrespective if where JS included in page.

it might be a very simple solution but I very new for Java Script and have to implement this. appreciate any help here.

I loved as mch a u ill receive carried ut ight

ere. sketch

attractive, ur authored subject matter stylish.

noneheless, u command t ot n nervousness r t u ish delivering ollowing.

unwell unquestionably ome ore ormerly gain xactly ame nerly ery ften nside ase u shield increase.

This is a good tip especially to those new to the blogosphere.

Brief but very precise information Thank you for sharing this one.

Your detailed blog is very attractive and useful. It really helps other to get such information. Keep doing work. Let me know any new and interesting stuff, will put a trackback to this post!

you dont need to register the element with JS. that is just good practice

You wont be able to define an API for your element unless you use registerElement().

Email Address (will not be published)*

Learn how to use JavaScript to add interactivity to websites.

Sign up for our newsletter, and well send you news and tutorials on web design, coding, business, and more!

AboutCareersBlogAffiliate ProgramTermsPrivacyPress KitContact

Sign up for our newsletter, and well send you news and tutorials on web design, coding, business, and more!

TheStudio

NEWS & OFFERS: FREE Design with Unlimited Edits FREE Shipping to Anywhere in the US Get a Guaranteed Quote Today and Get a Special First Order Discount

Endless creative potential for dozens of items – all at your fingertips.

Our design team helps you as much as you want during the creative process, free.

Enjoy access to over thousands of options – fulfilled by world-class factories.

Got a deadline? We ship overnight to beat them. And on non-rush orders, enjoy free standard shipping.

Were your supply chain in the cloud – customize your own product from scratch anytime, anywhere in the world.

The/Studio is your studio. With our vetted world-class factories, you can create the clothing and accessory items you want with exacting specifications no more time wasted trying to source manufacturers or struggling under costly production overheads. See how the the future is creating, with:

Our guarantee: great design, high quality, fast production. Every time.

Our factories power hundreds of brands every day from global names to hobby businesses. But if youre not convinced were the best fit, we encourage you to get a free quote below. Youll meet one of our sales representatives and explore one- on-one how The/Studio works uniquely for your business.

Embroidered PatchesWoven PatchesPrinted PatchesPVC Patches

Hang TagsCare Size LabelsFashion Brand LabelsBacker Cards

WristbandsSweatbandsPocket SquaresNeckwear

Money ClipsCufflinksTie BarsDog Tags

Topswooden keychainsDress ShirtsAthletic Shirts

Embroidery Coverage: 50% Embroidery

Embroidery Coverage: 75% Embroidery

Embroidery Coverage: 100% Embroidery

Looking for custom Patches? Were the best in the business. To prove it, heres

You will receive an additional 10% discount on your next purchase.

ypeMaker

LogotypeMaker provides a comprehensive Premium Package with everything you need to create and complete your branding.

Introducing a new LogotypeMaker application. A easy and intuitive interface lets you create your logo, customise, edit and download from your smartphone.

We believe in the power of creating great things individual. Merging hundreds of shapes, icons and fonts into a logo editor that help you create beautiful branding.

Custom Anime

This site is intended to give Anime fans a chance to have some fun by making their own custom avatar. Using the flash program above, you are able to build and save your own custom anime avatar!

If you have a blank screen above, be sure to install flash. Otherwise, check out ourfaqspage to see if that helps. Orcontact usif you get stuck.

Be sure to checkout the tips to the left – they explain how to use tools. You can move and resize anything, so be creative!

Check out the most recently made custome anime

Browse all the recent creations in ourAnime Gallery