Tutorial by Examples: c

The dot product between two tensors can be performed using: tf.matmul(a, b) A full example is given below: # Build a graph graph = tf.Graph() with graph.as_default(): # A 2x3 matrix a = tf.constant(np.array([[1, 2, 3], [2, 4, 6]]), ...
Variable tensors are used when the values require updating within a session. It is the type of tensor that would be used for the weights matrix when creating neural networks, since these values will be updated as the model is being trained. Declaring a variable tensor can be done using the tf.Varia...
XSS attacks consist in injecting HTML (or JS) code in a page. See What is cross site scripting for more information. To prevent from this attack, by default, Django escapes strings passed through a template variable. Given the following context: context = { 'class_name': 'large" style=&...
It is possible to create custom routing constraint which can be used inside routes to constraint a parameter to specific values or pattern. This constrain will match a typical culture/locale pattern, like en-US, de-DE, zh-CHT, zh-Hant. public class LocaleConstraint : IRouteConstraint { pri...
You can use raycasts to check if an ai can walk without falling off the edge of a level. using UnityEngine; public class Physics2dRaycast: MonoBehaviour { public LayerMask LineOfSightMask; void FixedUpdate() { RaycastHit2D hit = Physics2D.Raycas...
A Bag/ultiset stores each object in the collection together with a count of occurrences. Extra methods on the interface allow multiple copies of an object to be added or removed at once. JDK analog is HashMap<T, Integer>, when values is count of copies this key. TypeGuavaApache Commons Collec...
This multimap allows duplicate key-value pairs. JDK analogs are HashMap<K, List>, HashMap<K, Set> and so on. Key's orderValue's orderDuplicateAnalog keyAnalog valueGuavaApacheEclipse (GS) CollectionsJDKnot definedInsertion-orderyesHashMapArrayListArrayListMultimapMultiValueMapFastListMu...
Compare operation with collections - Create collections 1. Create List DescriptionJDKguavags-collectionsCreate empty listnew ArrayList<>()Lists.newArrayList()FastList.newList()Create list from valuesArrays.asList("1", "2", "3")Lists.newArrayList("1", &...
Suppose we want to count how many counties are there in Texas: var counties = dbContext.States.Single(s => s.Code == "tx").Counties.Count(); The query is correct, but inefficient. States.Single(…) loads a state from the database. Next, Counties loads all 254 counties with all of the...
Types of columns can be checked by .dtypes atrribute of DataFrames. In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': [True, False, True]}) In [2]: df Out[2]: A B C 0 1 1.0 True 1 2 2.0 False 2 3 3.0 True In [3]: df.dtypes Out[3]: A int64 ...
astype() method changes the dtype of a Series and returns a new Series. In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['1.1.2010', '2.1.2011', '3.1.2011'], 'D': ['1 days', '2 days', '3 days'], ...
select_dtypes method can be used to select columns based on dtype. In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'], 'D': [True, False, True]}) In [2]: df Out[2]: A B C D 0 1 1.0 a True 1 2 2.0 b False 2...
This example shows how to create a prepared statement with an insert statement with parameters, set values to those parameters and then executing the statement. Connection connection = ... // connection created earlier try (PreparedStatement insert = connection.prepareStatement( "i...
To connect to MySQL you need to use the MySQL Connector/J driver. You can download it from http://dev.mysql.com/downloads/connector/j/ or you can use Maven: <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version...
When you create a function in TypeScript you can specify the data type of the function's arguments and the data type for the return value Example: function sum(x: number, y: number): number { return x + y; } Here the syntax x: number, y: number means that the function can accept two argum...
Example: function hello(name: string): string { return `Hello ${name}!`; } Here the syntax name: string means that the function can accept one name argument and this argument can only be string and (...): string { means that the return value can only be a string Usage: hello('StackOverfl...
You can search Docker Hub for images by using the search command: docker search <term> For example: $ docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. ...
public class MyObject{ public DateTime? TestDate { get; set; } public Func<MyObject, bool> DateIsValid = myObject => myObject.TestDate.HasValue && myObject.TestDate > DateTime.Now; public void DoSomething(){ //We can do this: if(this.TestDate....
Dart has a robust async library, with Future, Stream, and more. However, sometimes you might run into an asynchronous API that uses callbacks instead of Futures. To bridge the gap between callbacks and Futures, Dart offers the Completer class. You can use a Completer to convert a callback into a Fut...
GNU gettext is an extension within PHP that must be included at the php.ini: extension=php_gettext.dll #Windows extension=gettext.so #Linux The gettext functions implement an NLS (Native Language Support) API which can be used to internationalize your PHP applications. Translating strings ...

Page 234 of 826