text:
# jzhao.xyz

.
\_.
/

# Atlas of AI

Last updated March 23, 2022

“It is the idealogy of Cartesian dualism in AI: where AI is narrowly understood as disembodied intelligence, removed from any relation to the material world.” – they absorb and produce knowledge independently from their creators, infrastructures, and the world at large.

“To understand how AI is fundamentally political, we need to go beyond neural nets and statistical pattern recognition to instead ask what is being optimized, and for whom, and who gets to decide.”

“As author and engineer Ellen Ullman puts it, this belief that the mind is like a computer, and vice versa, has infected decades of thinking in the computer and cognitive sciences,’ creating a kind of original sin for the field. It is the idealogy of Cartesian dualism in artificial intelligence: where AI is narrowly understood as disembodied intelligence, removed from any relation to the material world.”

“An atlas is an unusual type of book. It is a collection of disparate parts, with maps that very in resolution from a satellite view of the planet to a zoomed-in detail of an archipelago. When you open an atlas, you may be seeking specific information about a particular place – or perhaps you are wandering, following your curiosity, and finding unexpected pathways and new perspectives.”

AI is an attempt to be the atlas – the dominant way of seeing the world. We should instead try to construct “humble geography” that acknowledges one’s specific perspectives rather than claiming objectivity or mastery.

“In this sense, artificial intelligence is a registry of power… Computational reason and embodied work are deeply interlinked: AI systems both reflect and produce social relations and understanding of the world.”

## # Hans: Observer-expectancy effect

“Their intuition was right: the questioner’s posture, breathing, and facial expression would subtly change around the moment Hans reached the right answer, prompting Hans to stop there.”

“The story of Clever Hans is compelling from many angles: the relationship between desire, illusion, and action, the business of spectacles, how we anthropomorphize the nonhuman, how biases emerge, and the politics of intelligence.”

“Even a system that appears to perform spectacularly in training can make terrible predictions when presented with novel data in the world.”

## # Earth

“Commerce follows the flag, but the flag follows the pick.”

“Those who profit from mining do so only because the costsd must be sustained by others, those living and those not yet born. It is easy to put a price on precious metals, but what is the exact value of a wilderness, a clean stream, breathable air, the health of local communities?”

“It was the ‘move fast and break things’ of a different time”

“The mines were located far from the city they enriched, and this remoteness allowed city dwellers to remain ignorant of what was happening to the mountains, rivers, and laborers that fed their fortunes.”

## # Labour

Megamachine: illustration of how all systems, no matter how immense, consist of the work of many individual human actors.

Humans are increasingly treated like robots or the connective tissue between robots.

Potemkin AI systems are a form of deception perpetrated by technology vendors eager to stake a claim in the lucrative tech space. The difference between ‘perceived’ ability and ‘real’ ability of these AI system are augmented by human piecework.

## # Data

There is a new pervasive belief that everything is data and is there for the taking.

Data, when aggregated, become infrastructure. “The meaning or care that might be given to the image of an individual person, or the context behind a scene, is presumed to be erased at the moment it becomes part of an aggregate mass that will drive a broader system.”

ML systems work based on inductive inference. Any person who has taken a first-year course on logic will know the false conclusions that this can draw (e.g. all swans are white). Can we create systems that operate on deductive inference, which follows logically from a premise?

“Even the largest troves of data cannot escape the fundamental slippages that occur when an infinitely complex world is simplified and slices into categories.” This is a process that requires inherently political, cultural, and social choices.

“Data systems allowed scientists during wartime to operate at a psychological distance from the people ‘who would be maimed and killed by the weapons systems that would result from the ideas they communicated’.”

## # Recognition Systems

“This is the danger of affect recognition tools. As we’ve seen, they take us back to the phrenological past, where spurious claims were made, allowed to stand, and deployed to support existing systems of power.”

## Accountability

Andrew Ferguson: “We are moving to a state where prosecutors and police are going to say ’the algorithm told me to do it, so I did, I had no idea what I was doing’.”

A false objectivity, “it’s just math, math can’t be biased, right?”

The historian of technology Alex Campolo calls this enchanted determinism: “AI systems are seen as enchanted, beyond the known world, yet determinisitc in that they discover patterns that can be applied with predictive certainty to everyday life.”


text:
Or, at least, that’s what this blog post at Science and Math Defeated aims to do. Normally, I avoid writing on such a topic but I think the following example could be instructive to a few people, at least, in learning how not to infer from mathematical induction. The author of that blog post sets to “disprove” the foundation of Calculus by showing that the “assumption” $0.999 \ldots = 1$ leads to a contradiction (which I am sure most of you have seen before.) And this is supposed to be achieved  through the use of Mathematical Induction.

Let $P(n)$ be the statement $\displaystyle 0.\underbrace{999...9}_{n \, 9's} < 1$ for all $n \in \mathbb{N}$ and $n \ge 1$.

Claim: $P(n)$ is true for all $n \ge 1$.

Proof: $0.9 < 1$, and so, $P(1)$ is true. This takes care of the base case. Now assume $P(n)$ is true for some $k \in \mathbb{N}$, where $k \geq 1$. Now, it is easy to show that $P(k+1)$ is true as well (I just skipped some details!). Hence, $P(k) \Rightarrow P(k+1)$ holds. This takes care of the induction step. (Note that $P(k+1)$ is shown to be true independent of $P(k)$!) And, this proves our claim.

(Erroneous) Conclusion: Hence, $0.999\ldots < 1$.

Notwithstanding the inductive proof (which is correct) above, why is the above conclusion wrong?

Ans. Because “infinity” is not a member of $\mathbb{N}$.

(Watch out for Todd’s next post in the ETCS series!)

format: plain


text:
# Did I do anything wrong in this limit evaluation?

1. Mar 8, 2012

### pylauzier

1. The problem statement, all variables and given/known data

A problem in my book asks the reader to evaluate lim x→0 xln(2x) using L'Hôpital.

2. Relevant equations

None

3. The attempt at a solution

I think I got it right but I simply wanted to make sure I did no illegal manipulations (I'm self-studying this stuff).

I started by substituting u = 1/x to get an undeterminate form suitable for L'Hôpital. By doing so, lim x→0 becomes lim u→∞

lim x→0 xln(2x) = lim u→∞ ln(2/u) / u

Applying L'Hôpital:

= lim u→∞ (-u)/2u2

= lim u→∞ (-1)/2u

= 0

I know that's the right answer, but did I make any mistakes? Also, was I allowed to switch lim x→0 by lim u→∞? Thanks in advance!

2. Mar 8, 2012

### Dick

Sure, it's right. You didn't even really need a substitution. Write the original limit as ln(2x)/(1/x) which is equally indeterminant. Then l'Hopital gives (1/x)/(-1/x^2)=(-x). That's still 0.

3. Mar 8, 2012

### pylauzier

Oh right, that sure is simpler. Thanks again!


text:
1. precalc

Find the indicated value, if f(x) = 4x - 17.

f -1(1)=

2. Inverse of a function

Find the indicated value, if f(x) = 4x - 17.

f -1(1)=
Use the same method as I showed you in http://www.mathhelpforum.com/math-he...ecalculus.html to find $f^{-1}(x)$, and then plug in the value x = 1.


text:
# Tag Info

Accepted

### Why is Markowitz portfolio optimisation so popular considering it is worse than an equal weighted portfolio?

Markowitz's concepts attracted a great deal of interest from theorists (and still do), but never had much application in practice. The results from practical application were always disappointing (...
• 9,462
Accepted

### cvxpy portfolio optimization with risk budgeting

The underlying problem: your ACTR constraints aren't convex The $i$th constraint on your risk contribution can be written: $$w_i \sum_j \sigma_{ij} w_j \leq c_i s$$ And this isn't a convex ...
• 6,334
Accepted

### Random Portfolios vs Efficient Frontier

You seem to have two distinct problems: How to generate random portfolios How optimal portfolios are structured Ad 1) A straightforward way to simulate the weights of random portfolios is to use ...
• 1,933

• 116
Accepted

### What's the importance of duality theory in portfolio optimization?

That's a pretty heavy question for this forum, and its answer is worthy of a semester-long discussion in a university course. The short answer is that (for convex optimization) the dual problem can ...
• 511
Accepted

### How to apply Levenberg Marquardt to Max Likelihood Estimation

An AR(1), once the time series and lags are aligned and everything is set-up, is in fact a standard regression problem. Let's look, for simplicity sake, at a "standard" regression problem. I will try ...
• 693

### Quantum Computing for Quantitative Finance

Try Quantum for Quants, which has contributions from people working actively in quantum computing, and some small scale examples solved on the D-Wave Systems Quantum Annealer. The picture below is ...
• 167

### Proof that linear returns aggregate across securities

I think you are simply confusing percentage weights and number of assets. In your definition the initial percentage weight of the $m$ assets in the portfolio are given by $w_i^{t - 1}$ and they sum ...
• 5,800
Accepted

### Derivation of the efficient frontier set (markowitz problem)

To solve this constraint minimization problem, first form the Lagrangian Function \begin{align} L(w,\lambda_1,\lambda_2)=w'\Sigma w + \lambda_1(w'\boldsymbol{\mu}-m) + \lambda_2 (w'\boldsymbol{1}-1). \...
• 177
Accepted

### Question on Rockafellar's Paper for optimisation of CVaR

On 1, I suspect that is a typo and that the second formula should sum to r. On 2, that is applying well-known techniques in how to handle piece-wise linear functions in an optimizer. For instance, ...
• 5,311
Accepted

### Optimisation with strong correlated Assets

This answer will try and outline all the different possibilities I came across over the last couple of years, including drawbacks. But first, let me outline the problem a little. To appreciate the ...
• 2,874
Accepted

• 5,763

### How to minimize Nelson-Siegel parametric form

When we worked with that model several years go, we used Differential Evolution and it worked very well. See Calibrating the Nelson-Siegel-Svensson Model. At least in the standard version, a best-of-...
• 2,876

### What is the reference python library for portfolio optimization?

Convex Optimisation - CVXOpt and CVXPy. Textbook by Boyd & Vandenberghe Aside from CVXOPT (known for its cone programming, see http://cvxopt.org/) with extensive documentation by the authors, ...
• 1,018


text:
We demonstrate DeMorgan’s theorem in action.

DeMorgan makes it easier to read logic diagrams and lets you clearly show your design intent. Your logic designs become easier to understand and much easier to get right.

Written by Willy McAllister.

### Contents

Substitute DeMorgan symbols into a schematic to pair up inversion bubbles so they cancel. The logic becomes much easier to understand.

Let’s demonstrate how to use DeMorgan’s theorem with this logic diagram,

What does this logic do?

There are three possible approaches you could take to explore this circuit,

• Write out a truth table with 4 input columns, 1 output column, and $2^4 = 16$ rows.
• Write a Boolean equation and simplify it with DeMorgan’s theorem.
• Draw a logic schematic with DeMorgan symbols to reveal the function.

The truth table with 16 rows is a bit too cumbersome for this problem. It’s hard to identify the logic pattern. But feel free to give it a try if you want. We will do the second and third alternatives.

## Boolean algebra

For the Boolean equation, see if you can write out the logic equation represented by this circuit. Give it a try. Then apply DeMorgan’s theorem and simplify the equation as much as possible.

To get started we label the two intermediate nodes. The two gates on the left produce the NAND of their inputs,

Now write out the logic expression for the whole thing. The output is the NAND of the two intermediate terms,

E = (A B) · (C D)

Can you tell what this function does? (hint: I can’t.) Let’s see if it helps to apply the one digital theorem we know, DeMorgan’s theorem,

A · B = A + B $\quad$ (NAND form)

A + B = A · B $\quad$ (NOR form)

Our equation for E resembles the first form of DeMorgan’s theorem (the NAND form). It has a long bar above two expressions joined by an AND operation. Let’s use the second memory trick we made up for DeMorgan’s theorem. Here’s a reminder,

• If you have two variables under a common bar — either A · B or A + B
• Break the bar into two individual bars and flip to the opposite operator,
• A · B turns into A + B
• A + B turns into A · B

The original equation for E with its long top bar,

E = (A B) · (C D)

becomes,

E = (A B) + (C D)

The double bars over the two separate expressions cancel and we end up with,

E = A B + C D

This is as simple as we can make it. Our logic circuit performs two AND operations and OR’s together the intermediate results. In digital jargon this is called a 2-2 AND-OR. Another name for it is Sum-of-Products.

## DeMorgan logic diagram

Next we’ll redraw a schematic, this time with the DeMorgan NAND symbol for the third gate.

Here’s where something cool happens. Notice how bubbles appear on both ends of the intermediate nodes. Conceptual experiment: If we pull the bubbles slightly away from their gate symbols we observe the signals just before the output bubbles and just after the input bubbles. (Note: You can’t physically pull the bubbles off a real NAND gate, but you certainly can nudge the bubbles in your imagination.)

In the diagram above, AB emerges from the top left AND symbol, it gets inverted twice, and AB is the input to the OR symbol. It’s as if the two bubbles aren’t even there. The same thing happens to CD on the lower path. Invert something twice and you get the original input. If you select logic symbols so bubbles appear on both ends of a node, the bubbles cancel each other.

With the DeMorgan gate symbol for the third NAND we’ve turned the circuit into this,

And with a glance you can read off the logic function,

E = A B + C D

The answer falls out with almost no effort.

It’s important to remember—we do not change the underlying hardware circuit as we do these logic transformations—the gates are still NANDs—but we’ve drawn an equivalent logic diagram that does the same thing.

This bubble-cancellation trick is the superpower of DeMorgan’s theorem. After you get good at this you won’t have to redraw the schematic like I did here. Instead you stick with the original version with the DeMorgan NAND,

Pass you eyes over the circuit. Look for pairs of bubbles on either end of a node. When you find bubble pairs you know they can be ignored. The circuit becomes bubble-free and much easier to read.

When bubbles match up the circuit better reflects your design intent. Our example is an AND-OR logic function, which is exactly what the schematic looks like when we use the DeMorgan symbol. The original schematic with three conventional NAND symbols gives no hint of the logic function it performs. That version of the schematic hides the design intent, which is evil. Don’t do to yourself or anyone else who uses your work.

But what if you don’t find pairs of bubbles? You work out the logic function with careful algebra. But before you dive into algebra do everything you can to replace regular symbols with DeMorgan symbols to create as many bubble pairs as you can.

## DeMorgan practice

What does this logic do?

Hint: Find the answer fastest by with a DeMorgan symbol.

Change the third NOR gate to it’s DeMorgan equivalent symbol. All the bubbles match up,

E = (A + B) · (C + D)

You can call this a Product-of-Sums function.

What does this logic do?

Use a DeMorgan symbol for the NOR gate to pair up bubbles,

E = ABCD

This implements a 4-input AND function with three 2-input gates. The DeMorgan symbol better reflects the intended function. With practice, your eyes will see the matched bubbles and you won’t have to redraw the circuit. To understand the logic function just read the gate shapes.

What does this logic do?

Use a DeMorgan symbol for the first NAND to change its output bubble to a pair of bubbles on the input side. This achieves a no-bubble connection to the central pair of gates.

Use a DeMorgan symbol for the last NAND gate to pair up bubbles with the outputs of the central pair of gates,

Label the internal node, read off the logic, and do a little bit of Boolean algebra,

E = A·( A + B ) + ( A + B )·B

E = AA + AB + AB + BB

The AA and BB terms evaluate to 0, so they drop out. This leaves,

E = AB + AB

We recognize this as the exclusive OR function,

E = A $\oplus$ B

This is an XOR created with the fewest possible 2-input NAND gates.

This problem shows how you can use a DeMorgan symbol to move a bubble away from a node to achieve a no-bubble node.

Extra credit 1: Redraw the original circuit with NOR gates instead of NANDs. Do the problem again. It should produce an XNOR function.

Extra credit 2: If you want to put yourself through some extra pain try to do the problem with Boolean algebra starting from the original all-NAND schematic. So tedious. It makes you appreciate the power of DeMorgan’s theorem and the schematic representation of logic.

## Summary

DeMorgan symbols are a graphical representation of DeMorgan’s theorem.

There are two reasons we substitute DeMorgan symbols into a schematic—to get inversion bubbles to pair up and cancel—and to match up a bubble with a signal name that is negated, such as RESET or Enable-. When you do this the logic reflects the design intent and it much easier to understand.

You should use DeMorgan symbols every time you draw logic. Some designers consider a logic diagram correct only if DeMorgan symbols are properly used. You can draw functionally correct logic without DeMorgan symbols, but if the symbols don’t clearly convey the intended function, your diagram is “wrong” or at best low quality.

The main purpose of a logic diagram is to document the intended function. If someone who reads your diagram is forced into complex logic transformations to understand the logic there is a great risk of error. You waste everyone’s time, especially your own. You will read your own schematic two weeks or two months from now and wonder what it does. Save yourself a lot of pain. DeMorgan!


text:
# Explaining the proof of Fibonacci number using inductive reasoning

Fibonacci numbers are defined as follows.

$$F_{1}= F_{2} = 1$$ When $$n \geq 3$$, $$F_{n} = F_{n-1} + F_{n-2}$$

Task: Prove the following statement using mathematical induction:

• When $$n \geq 2$$, $$F_{n-1}F_{n+1} = F_{n}^2 + (-1)^n$$

The Base Case:

The Inductive Step:

I'm really confused about the inductive step. The answer makes absolutely no sense to me.

Questions:

1. For the inductive step, why is the yellow area equal to the green area?
2. For the inductive step, how do we arrive at the purple and red statement?

I think the answer given to me is too simplified and doesn't demonstrate a clear logical reasoning.

• My apologies for anyone who is color blind. It's just easier for me to color code the statements. Dec 9, 2018 at 22:18

1. The green part is $$f^2(k)+f(k)f(k+1)=(f(k-1)+f(k))f(k+1)-(-1)^k=f^2(k+1)+(-1)^{k+1},$$ i.e. the yellow part. Note that it's not supposed to be obvious at this stage that green = yellow; that they are is what the subsequent lines show. The important part is that red = yellow; that's why the inductive step works. The way the proof of this actually starts is by rewriting $$f(k+2)$$ as a sum to get the green expression.
2. The purple part is equal to the line above it, by summing the coefficients of $$f(k+1)$$ and taking care with powers of $$-1$$. The red part rewrites the summed coefficient from the recursion relation, and then notes a square is present.
1. Because, by definition, $$f(k+2)=f(k+1)+f(k)$$.
2. First of all, $$-(-1)^k=(-1)\times(-1)^k=(-1)^{k+1}$$. Then,$$f(k)f(k+1)+f(k-1)f(k+1)=\bigl(f(k)+f(k-1)\bigr)f(k+1).$$So,$$f(k)f(k+1)+f(k-1)f(k+1)-(-1)^k=\bigl(f(k)+f(k-1)\bigr)f(k+1)+(-1)^{k+1}.\tag1$$But, by definition, $$f(k+1)=f(k)+f(k-1)$$. So, $$(1)$$ becomes$$f(k)f(k+1)+f(k-1)f(k+1)-(-1)^k=\bigl(f(k+1)\bigr)^2+(-1)^{k+1}.$$


text:
Sign In Sign Up
 Magyar Information Contest Journal Articles

# Problem C. 1006. (November 2009)

C. 1006. Prove that six-digit numbers of the form cannot have prime factors of more than two digits.

(5 pont)

Deadline expired on 10 December 2009.

Sorry, the solution is available only in Hungarian. Google translation

Megoldás. $\displaystyle \overline{ababab}=10101(10a+b)=3 \cdot 7 \cdot 13 \cdot 37 \cdot \overline{ab}$. Mivel $\displaystyle \overline{ab}$ kétjegyű, ezért legfeljebb kétjegyű prímosztója lehet csak.

### Statistics:

 367 students sent a solution. 5 points: 281 students. 4 points: 47 students. 3 points: 14 students. 2 points: 16 students. 1 point: 1 student. 0 point: 3 students. Unfair, not evaluated: 5 solutions.

 Our web pages are supported by: Morgan Stanley


text:
## LaTeX forum ⇒ Page Layout ⇒ Custom Cover Page Topic is solved

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
PulpFan
Posts: 9
Joined: Thu Aug 08, 2019 8:01 pm

### Custom Cover Page

I am not using \maketitle, I am using the following code:

As I currently do not have license to use the image and have the paragraph at the very end, it works.

However if I comment out the note to myself that it is not licensed, as I will do when it is licensed, LaTeX does not seem to see textblock as content for the page with the CoverArt.png and as a result the title page with the CoverArt.png is not typeset and the textblock declarations are typeset on top of the next page, resulting in the content that is suppose to be the second page being the first page.

I'm sure there is a simple solution to this?

PulpFan
Posts: 9
Joined: Thu Aug 08, 2019 8:01 pm
Solved this by adding

\begin{pgfpicture}{0cm}{0cm}{1cm}{1cm}\end{pgfpicture}

So there's a transparent box on the page and it doesn't need text to use the \AddToShipoutPicture*{} and the manually placed textblock areas.

### Who is online

Users browsing this forum: No registered users and 2 guests


text:
# Super-Eddington Accretion onto the Neutron Star NGC 7793 P13: Broadband X-ray Spectroscopy and Ultraluminous X-ray Sources

Abstract : We present a detailed, broadband X-ray spectral analysis of the ULX pulsar NGC 7793 P13, a known super-Eddington source, utilizing data from the $XMM$-$Newton$, $NuSTAR$ and $Chandra$ observatories. The broadband $XMM$-$Newton+NuSTAR$ spectrum of P13 is qualitatively similar to the rest of the ULX sample with broadband coverage, suggesting that additional ULXs in the known population may host neutron star accretors. Through time-averaged, phase-resolved and multi-epoch studies, we find that two non-pulsed thermal blackbody components with temperatures $\sim$0.5 and $\sim$1.5 keV are required to fit the data below 10 keV, in addition to a third continuum component which extends to higher energies and is associated with the pulsed emission from the accretion column. The characteristic radii of the thermal components appear to be similar, and are too large to be associated with the neutron star itself, so the need for two components likely indicates the accretion flow outside the magnetosphere is complex. We suggest a scenario in which the thick inner disc expected for super-Eddington accretion begins to form, but is terminated by the neutron star's magnetic field soon after its onset, implying a limit of $B \lesssim 6 \times 10^{12}$ G for the dipolar component of the central neutron star's magnetic field. Evidence of similar termination of the disc in other sources may offer a further means of identifying additional neutron star ULXs. Finally, we examine the spectrum exhibited by P13 during one of its unusual 'off' states. These data require both a hard powerlaw component, suggesting residual accretion onto the neutron star, and emission from a thermal plasma, which we argue is likely associated with the P13 system.
Type de document :
Article dans une revue
Monthly Notices of the Royal Astronomical Society, Oxford University Press (OUP): Policy P - Oxford Open Option A, 2018, 473 (4), pp.4360-4376. 〈10.1093/mnras/stx2650〉
Domaine :

https://hal.archives-ouvertes.fr/hal-01669692
Contributeur : Inspire Hep <>
Soumis le : jeudi 21 décembre 2017 - 00:03:07
Dernière modification le : jeudi 11 janvier 2018 - 16:54:55

### Citation

D.J. Walton, F. Furst, F.A. Harrison, D. Stern, M. Bachetti, et al.. Super-Eddington Accretion onto the Neutron Star NGC 7793 P13: Broadband X-ray Spectroscopy and Ultraluminous X-ray Sources. Monthly Notices of the Royal Astronomical Society, Oxford University Press (OUP): Policy P - Oxford Open Option A, 2018, 473 (4), pp.4360-4376. 〈10.1093/mnras/stx2650〉. 〈hal-01669692〉

### Métriques

Consultations de la notice


text:
# Working with Tensors

In Deep.Net a tensor is an n-dimensional array of an arbitrary data type (for example single, double or System.Numerics.Complex). Tensors are implemented by the ArrayNDT<'T> class and its derivatives ArrayNDHostT (for tensors stored in host memory) and ArrayNDCudaT (for tensors stored in CUDA GPU memory). The Deep.Net tensor provides functionality similar to Numpy's Ndarray and MATLAB arrays, including vector-wise operations, reshaping, slicing, broadcasting, masked assignment, reduction operations and BLAS operations. The API for host and GPU stored tensors is equal, thus a program can make use of GPU accelerated operations without much porting effort.

You can run this example by executing FsiAnyCPU.exe docs\content\tensor.fsx after cloning the Deep.Net repository. You can move your mouse over any symbol in the code samples to see the full signature.

## Architecture

To work with the tensor library, open the ArrayNDNS namespace.

 1:  open ArrayNDNS

The tensor library consists of three primary modules: ArrayND, ArrayNDHost, ArrayNDCuda. ArrayND contains functions to work with existing tensors (regardless of their storage location) such as reshape, sum, and copy. ArrayNDHost contains functions to create new tensors in host memory, for example zeros, ones and ofList. ArrayNDCuda contains functions to create new tensors in CUDA GPU memory and to facilitate the transfer of tensors between host and GPU memory, for example zeros, toDev and fromDev.

A tensor stored in host memory is of type ArrayNDHostT<'T> where 'T is the contained data type. Correspondingly a tensor stored in CUDA GPU memory is of type ArrayNDCudaT<'T>. Both types are derived from ArrayNDT<'T>.

## Creating tensors

Let us create a simple $$7 \times 5$$ matrix, i.e. two-dimensional tensor, in host memory.

 1:  let a = ArrayNDHost.initIndexed [7; 5] (fun [i; j] -> 5.0 * float i + float j)

The first argument to the ArrayNDHost.initIndexed function is an F# list specifies the shape of the tensor. The second argument is a function that takes the n-dimensional index (zero-based) of an entry and computes its initial value; here we use the formula $$5i + j$$ where $$i$$ is the row and $$j$$ is the column of the matrix. The data type (here float) is automatically inferred from the return type of the initialization function. By default row-major storage (C storage order) is used.

The resulting tensor has the following entries.

 1: 2: 3: 4: 5: 6: 7:  [[ 0.0000 1.0000 2.0000 3.0000 4.0000] [ 5.0000 6.0000 7.0000 8.0000 9.0000] [ 10.0000 11.0000 12.0000 13.0000 14.0000] [ 15.0000 16.0000 17.0000 18.0000 19.0000] [ 20.0000 21.0000 22.0000 23.0000 24.0000] [ 25.0000 26.0000 27.0000 28.0000 29.0000] [ 30.0000 31.0000 32.0000 33.0000 34.0000]]

We can also create a tensor filled with zeros using the ArrayNDHost.zeros function.

 1:  let z1 : ArrayNDHostT = ArrayNDHost.zeros [3]

In this case we must specify the data type (int) explicitly, since there is no information in the function call to infer it automatically.

We can use the ArrayNDHost.ones function to obtain a tensor filled with ones.

 1:  let o1 : ArrayNDHostT = ArrayNDHost.ones [3]

The ArrayNDHost.identity function creates an identity matrix of the given size.

 1:  let id1 : ArrayNDHostT = ArrayNDHost.identity 6

This created a $$6 \times 6$$ identity matrix.

A tensor of rank zero can be created with the ArrayNDHost.scalar function.

 1:  let s1 = ArrayNDHost.scalar 33.2

The numeric value of a zero-rank tensor can be extracted using the ArrayND.value function.

 1:  printfn "The numeric value of s1 is %f." (ArrayND.value s1)

### Creation from F# sequences, lists and arrays

The ArrayNDHost.ofSeq converts a F# sequence of finite length into a one-dimensional tensor. For example, the code

 1:  let seq1 = seq { for i=0 to 20 do if i % 3 = 0 then yield i } |> ArrayNDHost.ofSeq

creates a vector of all multiplies of 3 in the range between 0 and 20:

 1:  seq1 = [ 0 3 6 9 12 15 18]

A list can be converted into a one-dimensional tensor using the ArrayNDHost.ofList function.

To convert an array into a tensor use the ArrayNDHost.ofArray function. The ArrayNDHost.ofArray2D and ArrayNDHost.ofArray3D take two-dimensional and three-dimensional arrays and convert them into tensors of respective shapes.

### Conversion to F# lists and arrays

Use the ArrayNDHost.toList function to convert a tensor into a list. A multi-dimensional tensor is flattened before the conversion.

Use the ArrayNDHost.toArray, ArrayNDHost.toArray2D and ArrayNDHost.toArray3D to convert a tensor into an array of respective dimensionality.

## Printing tensors

Tensors can be printed using the %A format specifier of the standard printf function.

 1: 2: 3: 4:  printfn "The tensor a is\n%A" a printfn "The tensor z1 is\n%A" z1 printfn "The tensor o1 is\n%A" o1 printfn "The tensor id1 is\n%A" id1

The output of large tensors is automatically truncated to a reasonable size.

## Accessing elements

Individual elements of a tensor can be accessed using the tensor.[[idx0; idx1; ...; idxN]] notation. Zero-based indexing is used. For example

 1:  a.[[1; 1]]

accesses the element at index $$1,1$$ and returns 5.0. Note that the indices are specified with double brackets ([[ and ]]) and separated using a semicolon.

Tensors are mutable objects. An element can be changed using the tensor.[[idx0; idx1; ...; idxN]] <- newValue notation. For example

 1:  a.[[2; 2]] <- 55.

changes the tensor to

 1: 2: 3: 4: 5: 6: 7:  [[ 0.0000 1.0000 2.0000 3.0000 4.0000] [ 5.0000 6.0000 7.0000 8.0000 9.0000] [ 10.0000 11.0000 55.0000 13.0000 14.0000] [ 15.0000 16.0000 17.0000 18.0000 19.0000] [ 20.0000 21.0000 22.0000 23.0000 24.0000] [ 25.0000 26.0000 27.0000 28.0000 29.0000] [ 30.0000 31.0000 32.0000 33.0000 34.0000]]

## Slicing

Slicing creates a new view into an existing tensor. Slicing is done using the tensor.[rng0, rng1, ..., rngN] notation. Note that the ranges are specified within single brackets and separated using commas.

Let us select the first row of tensor a.

 1:  let a1 = a.[0, *]

The asterisk selects all elements of the specified dimension. The result is a tensor of rank one (i.e. a vector) with the entries

 1:  [ 0.0000 1.0000 2.0000 3.0000 4.0000]

Since a1 is a view of a it shares the same memory. Changing an element of a1 by assigning a new value to it

 1:  a1.[[1]] <- 99.

changes the tensor a as well. This can be seen by outputting a1 and a.

 1: 2:  printfn "a1 is now\n%A" a1 printfn "a is now\n%A" a

The corresponding output is

  1: 2: 3: 4: 5: 6: 7: 8: 9: 10:  a1 is now [ 0.0000 99.0000 2.0000 3.0000 4.0000] a is now [[ 0.0000 99.0000 2.0000 3.0000 4.0000] [ 5.0000 6.0000 7.0000 8.0000 9.0000] [ 10.0000 11.0000 55.0000 13.0000 14.0000] [ 15.0000 16.0000 17.0000 18.0000 19.0000] [ 20.0000 21.0000 22.0000 23.0000 24.0000] [ 25.0000 26.0000 27.0000 28.0000 29.0000] [ 30.0000 31.0000 32.0000 33.0000 34.0000]]

The slicing notation can also be used for changing multiple elements of a tensor at once. For example

 1: 2:  let a2 : ArrayNDHostT = ArrayNDHost.ones [5] a.[0, *] <- a2

sets all elements of the first row of a to 1. The tensor a is now

 1: 2: 3: 4: 5: 6: 7:  [[ 1.0000 1.0000 1.0000 1.0000 1.0000] [ 5.0000 6.0000 7.0000 8.0000 9.0000] [ 10.0000 11.0000 55.0000 13.0000 14.0000] [ 15.0000 16.0000 17.0000 18.0000 19.0000] [ 20.0000 21.0000 22.0000 23.0000 24.0000] [ 25.0000 26.0000 27.0000 28.0000 29.0000] [ 30.0000 31.0000 32.0000 33.0000 34.0000]]

### Slicing operations

Consider the two-dimensional tensor a of shape $$7 \times 5$$ and the four-dimensional tensor b of shape $$1 \times 2 \times 3 \times 4$$. A slice range can be one of the following.

• A range, e.g. 1..3. Selects the specified elements in the corresponding dimension. For example a.[1..3, 0..2] is the $$3 \times 3$$ sub-tensor of a containing rows 1, 2, 3 and columns 0, 1, 2. The ending index is inclusive.
• A partial range, e.g. 1.. or ..3. This selects all elements in the corresponding dimension to the end or from the beginning respectively. Thus a.[1.., ..3] is equivalent to a.[1..6, 0..3].
• An asterisk *. Selects all elements in the corresponding dimension. For example a.[1..3, *] is equivalent to a.[1..3, 0..4].
• An integer. The corresponding dimension collapses, e.g. a.[*, 0] specifies a one-dimensional tensor of shape $$7$$ corresponding to the first column of a.
• The special identifier NewAxis. It inserts a new axis of size one at the given position. For example a.[*, NewAxis, *] produces a view of shape $$7 \times 1 \times 5$$.
• The special identifier Fill. It fills any dimensions not specified (if any) with an asterisk *. For example b.[0, Fill, 2] is equivalent to b.[0, *, *, 4] and results into a two-dimensional view into tensor b.

All slice range operators can be combined arbitrarily.

The reader should note that the result of selecting a single element using the slicing operator, e.g. a.[1,1], is a tensor of dimension zero sharing the same memory as a.

## Shape operations

### Getting the shape

The shape of a tensor can be accessed using the function ArrayND.shape or using the Shape property. Both methods return a list. The rank (number of dimensions) can be accessed using the function ArrayND.nDims or with the NDims property. The number of elements can be accessed using the function ArrayND.nElems or with the NElems property. For example

 1:  printfn "a has shape %A, rank %d and %d elements." a.Shape a.NDims a.NElems

prints

 1:  a has shape [7; 5], rank 2 and 35 elements.

### Reshaping

Reshaping changes the shape of the tensor while keeping the number of elements constant.

For example consider the $$4 \times 4$$ matrix b,

 1:  let b = ArrayNDHost.initIndexed [4; 4] (fun [y; x] -> 4 * y + x)

with value

 1: 2: 3: 4:  [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [ 12 13 14 15]]

We can use the ArrayND.reshape function to transform this matrix into a vector of length 16.

 1:  let b1 = ArrayND.reshape [16] b

Now b1 has the value

 1:  [ 0 1 2 3 4 5 ... 12 13 14 15]

We can also specify -1 for the new size of at most one dimension. In this case its size will be chosen automatically (so that the number of elements does not change). For example

 1:  let b2 = ArrayND.reshape [4; 2; -1] b

reshapes b into a three dimensional tensor of shape $$4 \times 2 \times 2$$ with the value

 1: 2: 3: 4: 5: 6: 7: 8:  [[[ 0 1] [ 2 3]] [[ 4 5] [ 6 7]] [[ 8 9] [ 10 11]] [[ 12 13] [ 14 15]]]

#### View or copy?

If the tensor to reshape has row-major order (C order), then ArrayND.reshape creates a new view into the existing tensor. Otherwise the tensor is copied during the reshape operation. If you need to ensure that no copy is performed, i.e. the original and reshaped tensor share the same memory, use the ArrayND.reshapeView function instead. It will raise an error if the original tensor is not in row-major order.

### Reordering axes and transposing

The ArrayND.swapDim function creates a new view of a tensor with the given dimensions swapped. For example

 1:  let b3 = ArrayND.swapDim 0 1 b

transpose the matrix b into

 1: 2: 3: 4:  [[ 0 4 8 12] [ 1 5 9 13] [ 2 6 10 14] [ 3 7 11 15]]

The original and tensor with swapped axes share the same memory and modifications made to one of them will affect the other one. A matrix can also be transposed using the ArrayND.transpose function or the .T method, i.e. ArrayND.transpose b and b.T both transpose the matrix b.

The ArrayND.reorderAxes function can reorder axes arbitrarily. It takes a list (of length equal to the rank of the tensor) with each element specifying the new position of the corresponding axis. The list must be a permutation of the axes indices, i.e. duplicating or leaving out axes is not permitted. Consider the rank three tensor b2 from above; then

 1:  let b4 = ArrayND.reorderAxes [2; 0; 1] b2

creates the view b4 with shape $$2 \times 2 \times 4$$. It is important to understand that each list entry specifies where the axis moves to, not where it is coming from. Thus, in this example, axis 0 becomes axis 2, axis 1 becomes axis 0 and axis 2 becomes axis 1.

The ArrayND.padLeft and ArrayND.padRight functions add a new axis of size one on the left or right respectively. If you need to add an axis at another position, use the slicing operator with the NewAxis identifier. For example

 1:  let b5 = b4.[*, *, NewAxis, *]

creates a view of shape $$2 \times 2 \times 1 \times 4$$.

An axis of size one can be repeated multiple times with the same value. This is called broadcasting. Consider the $$1 \times 4$$ matrix

 1:  let c = ArrayNDHost.initIndexed [1; 4] (fun [_; i] -> i)

with value

 1:  [[ 0 1 2 3]]

We can use the ArrayND.broadcastToShape function,

 1:  let c1 = ArrayND.broadcastToShape [3; 4] c

to obtain the tensor

 1: 2: 3:  [[ 0 1 2 3] [ 0 1 2 3] [ 0 1 2 3]]

Broadcasting creates a view of the original tensor, thus the repeated dimensions do not use additional memory and changing the broadcasted view will also change the original as well as all indices of a broadcasted dimension. Thus, in this example, executing

 1: 2: 3:  c1.[[1; 1]] <- 11 printfn "c1 is now\n%A" c1 printfn "c is now\n%A" c

prints

 1: 2: 3: 4: 5: 6:  c1 is now [[ 0 11 2 3] [ 0 11 2 3] [ 0 11 2 3]] c is now [[ 0 11 2 3]]

Broadcasting is also performed automatically when performing element-wise operations between two tensors of different, but compatible, shapes. This will be explained in the section about element-wise tensor operations.

## Tensor operations

The tensor type supports most standard arithmetic operators and arithmetic functions.

### Element-wise binary arithmetic operators

The elementary operators (+, -, *, /, %, **) are executed element-wise. For example, consider the vectors a and b,

 1: 2:  let d = ArrayNDHost.initIndexed [4] (fun [i] -> float i) let e = ArrayNDHost.initIndexed [4] (fun [i] -> 10. * float i)

with values

 1: 2:  d = [ 0.0000 1.0000 2.0000 3.0000] e = [ 0.0000 10.0000 20.0000 30.0000]

Then vector f,

 1:  let f = d + e

has the value

 1:  [ 0.0000 11.0000 22.0000 33.0000]

It is also possible to apply an operator to a tensor and a scalar of the same data type. In this case the scalar is broadcasted (repeated) to the size of the given tensor. For example

 1:  let d1 = d * 100.

results in

 1:  d1 = [ 0.0000 100.0000 200.0000 300.0000]

If a binary operator (for example +) is applied to two tensors of different shapes, the library tries to automatically broadcast both tensors to a compatible shape using the following rules.

1. If the tensors have different ranks, the tensor with the lower rank is padded from the left with axes of size one until both tensors have the same rank. For example, if a is of shape $$4 \times 3 \times 1$$ and b is of shape $$2$$, then b is padded to the shape $$\mathbf{1} \times \mathbf{1} \times 2$$.
2. For each dimension that has different size in both tensors and size one in one of the tensors, this dimension of the tensor with size one is broadcasted to the corresponding dimension of the other tensor. Thus, in our example, the last dimension of a is broadcasted resulting in the shape $$4 \times 3 \times \mathbf{2}$$ and the first and second dimensions of b are broadcasted resulting in the shape $$\mathbf{4} \times \mathbf{3} \times 2$$.

If the shapes still differ after applying the above rules, the operation fails.

### Element-wise arithmetic functions

The standard F# arithmetic functions, such as sin, cos, exp, log, can also be applied to tensors. For example

 1:  let f2 = sin f

calculates the sine of f element-wise.

### Element-wise function application

It is also possible to apply an arbitrary function element-wise using the ArrayND.map function. For example

 1:  ArrayND.map (fun x -> if x > 15. then 7. + x else -1.) f

produces the tensor

 1:  [ -1.0000 -1.0000 29.0000 40.0000]

An in-place variant that overwrites the original tensor is the ArrayND.mapInplace function. The ArrayND.map2 function takes two tensors and applies a binary function on their elements.

### Arithmetic reduction functions

The ArrayND.sum function computes the sum of all elements of a tensor and returns a zero-rank tensor. Thus, in our example

 1:  printfn "The sum of f is %.3f." (ArrayND.sum f |> ArrayND.value)

prints

 1:  The sum of f is 66.000.

The ArrayND.sumAxis function computes the sum over the given axis. Thus

 1: 2:  let g = ArrayNDHost.initIndexed [4; 4] (fun [y; x] -> 4 * y + x) ArrayND.sumAxis 0 g

computes the sums of all columns of the matrix

 1: 2: 3: 4:  [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [ 12 13 14 15]]

resulting in the vector

 1:  [ 24 28 32 36]

Likewise the ArrayND.product and ArrayND.productAxis compute the product of a tensor.

### Maximum and minimum

The ArrayND.min and ArrayND.max compute the minimum and maximum of a tensor and return a zero-rank tensor. Analogously ArrayND.minAxis and ArrayND.maxAxis compute the minimum and maximum over the given axis.

### Matrix multiplication

Matrix multiplication (dot product) is implemented using the .* operator. This operator can be used to calculate a vector/vector product resulting in a scalar, a matrix/vector product resulting in a vector and a matrix/matrix product resulting in a matrix.

For example

 1: 2: 3:  let h = ArrayNDHost.initIndexed [5; 3] (fun [i; j] -> 3. * float i + float j) let i = 0.1 + ArrayNDHost.identity 3 let hi = h .* i

computes the matrix product of the $$5 \times 3$$ matrix h with the $$3 \times 3$$ matrix i resulting in the 5 \times 3 matrix hi.

### Tensor product

The tensor product between two tensors can be obtained using the %* operator or the ArrayND.tensorProduct function.

### Element-wise comparison operators

Element-wise comparisons are performed using the ==== (element-wise equal), <<<< (element-wise smaller than), >>>> (element-wise larger than) and <<>> (element-wise not equal) operators. They return a tensor of equal shape and boolean data type. For example

 1:  let j = d ==== e

has the value

 1:  d = [true; false; false; false;]

### Logic reduction operations

To check whether all elements satisfy a condition, use the ArrayND.all function after applying the element-wise comparison operator. To check whether at least one element satisfies a condition, use the ArrayND.any function after applying the element-wise comparison operator. Thus

 1:  d ==== e |> ArrayND.all

has the value false, but

 1:  d ==== e |> ArrayND.any

returns true.

### Element-wise logic operators

Element-wise logic operations are performed using the ~~~~ (element-wise negation), &&&& (element-wise and) and |||| (element-wise or) operators. Thus

 1:  ~~~~j

has value

 1:  [false; true; true; true;]

## Disk storage in HDF5 format

Tensors can be stored in industry-standard HDF5 files. Multiple tensors can be stored in a single HDF5 file and accessed by assigning names to them.

### Writing tensors to disk

The following code creates two tensors k and l and writes them into the HDF5 file tensors.h5 in the current directory.

 1: 2: 3: 4: 5: 6: 7:  open Basics // TODO: remove after refactoring let k = ArrayNDHost.initIndexed [5; 3] (fun [i; j] -> 3. * float i + float j) let l = ArrayNDHost.initIndexed [5] (fun [i] -> 2. * float i) let hdfFile = HDF5.OpenWrite "tensors.h5" ArrayNDHDF.write hdfFile "k" k ArrayNDHDF.write hdfFile "l" l hdfFile.Dispose ()

The resulting file can be viewed using any HDF5 viewer, for example using the free, cross-platform HDFView application as shown below.

The following code loads the tensors k and l from the previously created HDF5 file tensors.h5 and stores them in the variables k2 and l2.

 1: 2: 3: 4:  let hdfFile2 = HDF5.OpenRead "tensors.h5" let k2 : ArrayNDHostT = ArrayNDHDF.read hdfFile2 "k" let l2 : ArrayNDHostT = ArrayNDHDF.read hdfFile2 "l" hdfFile2.Dispose ()

The data types of k2 and l2 must be declared explicitly, since they must be known at compile-time. If the declared data type does not match the data type encountered in the HDF5, an error will be raised.

## Reading .npy and .npz files produced by Numpy

For compatibility, it is possible to read .npy and .npz files produced by Numpy. Not all features of the format are supported. Writing .npy and .npz files is not possible; use the HDF5 format instead.

Use the NPYFile.load function to read an .npy file and return its contents as an ArrayNDHostT. Use the NPZFile.Open function to open an .npz file and the Get method of the resulting object to obtain individual entries as ArrayNDHostT.

## CUDA GPU support

If your workstation is equipped with a CUDA capable GPU, you can transfer tensors to GPU memory and perform operations on the GPU. GPU tensors are instances of the generic type ArrayNDCudaT<'T> where 'T is the contained data type.

Note: While tensors can be created on or transferred to the GPU, currently there is no supported for accelerated operations on the GPU when using tensor directly. Thus executing tensor operations (except slicing and view operations) on the GPU will be very slow at the moment and should be avoided. This is supposed to change with future versions and does not affect compiled functions created by the Deep.Net library.

### Data transfer

Tensors can be transferred to the GPU by using the ArrayNDCuda.toDev function. Transfer back to host memory is done using the ArrayNDCuda.toHost function.

 1: 2:  let m = seq {1 .. 10} |> ArrayNDHost.ofSeq let mGpu = ArrayNDCuda.toDev m

mGpu is now a copy of m in GPU memory.

### Tensor creation

It is possible to create tensors directly in GPU memory. The function ArrayNDCuda.zeros, ArrayNDCuda.ones, ArrayNDCuda.identity and ArrayNDCuda.scalar behave like their ArrayNDHost counterparts, except that the result is stored on the GPU.

 1:  let n : ArrayNDCudaT = ArrayNDCuda.identity 4

Here we created a $$4 \times 4$$ identity matrix of data type float on the GPU.

### Operators and functions

All functions and operators described in previous section can be equally applied to GPU tensors. For example, the code

 1:  let mGpuSq = mGpu.[3..5] * 3

takes three elements from the GPU tensor and multiplies them by 3 on the GPU.

## Conclusion

We presented an introduction to working with host and GPU tensors in Deep.Net. Direct tensor manipulation will be used mostly for dataset and results handling. The machine learning model will instead be defined as a symbolic computation graph, that supports automatic differentiation and compilation to optimized CUDA code.

val a : obj

Full name: Tensor.a
Multiple items
val float : value:'T -> float (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.float

--------------------
type float = System.Double

Full name: Microsoft.FSharp.Core.float

--------------------
type float<'Measure> = float

Full name: Microsoft.FSharp.Core.float<_>
val z1 : obj

Full name: Tensor.z1
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
val o1 : obj

Full name: Tensor.o1
Multiple items
val single : value:'T -> single (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.single

--------------------
type single = System.Single

Full name: Microsoft.FSharp.Core.single
val id1 : obj

Full name: Tensor.id1
val s1 : obj

Full name: Tensor.s1
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
val seq1 : obj

Full name: Tensor.seq1
Multiple items
val seq : sequence:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Core.Operators.seq

--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>

Full name: Microsoft.FSharp.Collections.seq<_>
val i : int
val a1 : obj

Full name: Tensor.a1
val a2 : obj

Full name: Tensor.a2
val b : obj

Full name: Tensor.b
val b1 : obj

Full name: Tensor.b1
val b2 : obj

Full name: Tensor.b2
val b3 : obj

Full name: Tensor.b3
val b4 : obj

Full name: Tensor.b4
val b5 : obj

Full name: Tensor.b5
val c : obj

Full name: Tensor.c
val c1 : obj

Full name: Tensor.c1
val d : float

Full name: Tensor.d
val e : float

Full name: Tensor.e
val f : float

Full name: Tensor.f
val d1 : float

Full name: Tensor.d1
val f2 : float

Full name: Tensor.f2
val sin : value:'T -> 'T (requires member Sin)

Full name: Microsoft.FSharp.Core.Operators.sin
val g : 'a

Full name: Tensor.g
val h : 'a (requires member ( .* ))

Full name: Tensor.h
val i : float

Full name: Tensor.i
val hi : '_arg3

Full name: Tensor.hi
val k : 'a

Full name: Tensor.k
val l : 'a

Full name: Tensor.l
val hdfFile : 'a

Full name: Tensor.hdfFile
val hdfFile2 : 'a

Full name: Tensor.hdfFile2
val k2 : 'a

Full name: Tensor.k2
val l2 : 'a

Full name: Tensor.l2
namespace System
namespace System.IO
type File =
static member AppendAllLines : path:string * contents:IEnumerable<string> -> unit + 1 overload
static member AppendAllText : path:string * contents:string -> unit + 1 overload
static member AppendText : path:string -> StreamWriter
static member Copy : sourceFileName:string * destFileName:string -> unit + 1 overload
static member Create : path:string -> FileStream + 3 overloads
static member CreateText : path:string -> StreamWriter
static member Decrypt : path:string -> unit
static member Delete : path:string -> unit
static member Encrypt : path:string -> unit
static member Exists : path:string -> bool
...

Full name: System.IO.File
System.IO.File.Delete(path: string) : unit
val m : 'a

Full name: Tensor.m
val mGpu : 'a

Full name: Tensor.mGpu
val n : 'a

Full name: Tensor.n
val mGpuSq : int

Full name: Tensor.mGpuSq


text:
VS.

# Cap vs. Cup

Published:
Views: 2,422

Capnoun

A close-fitting hat, either brimless or peaked.

‘The children were all wearing caps to protect them from the sun.’;

Cupnoun

A concave vessel for drinking from, usually made of opaque material (as opposed to a glass) and with a handle.

‘Pour the tea into the cup.’;

Capnoun

A special hat to indicate rank, occupation etc.

Cupnoun

The contents of said vessel; a cupful.

‘I drank two cups of water but still felt thirsty.’;

Capnoun

Cupnoun

A customary unit of measure

Capnoun

A protective cover or seal

‘He took the cap off the bottle and splashed himself with some cologne.’;

Cupnoun

(US) A US unit of liquid measure equal to 8 fluid ounces (1/16 of a US gallon; 236.5882365 mL) or 240 mL.

Capnoun

A crown for covering a tooth

‘He had golden caps on his teeth.’;

Cupnoun

(Canada) A Canadian unit of measure equal to 8 imperial ounces (1/20 imperial gallon; 227.3 mL) or 250 mL.

Capnoun

The summit of a mountain etc.

‘There was snow on the cap of the mountain.’;

Cupnoun

A British unit of measure equal to 0.5 imperial pints (10 imperial ounces; 284 mL) or 300mL.

Capnoun

An artificial upper limit or ceiling

‘We should put a cap on the salaries, to keep them under control.’;

Cupnoun

A trophy in the shape of an oversized cup.

‘The World Cup is awarded to the winner of a quadrennial football tournament.’;

Capnoun

The top part of a mushroom

Cupnoun

A contest for which a cup is awarded.

‘The World Cup is the world's most widely watched sporting event.’;

Capnoun

A small amount of gunpowder in a paper strip or plastic cup for use in a toy gun

‘Billy spent all morning firing caps with his friends, re-enacting storming the beach at Normandy.’;

Cupnoun

(association football) The main knockout tournament in a country, organised alongside the league.

Capnoun

A small explosive device used to detonate a larger charge of explosives

‘He wired the cap to the bundle of dynamite, then detonated it remotely.’;

Cupnoun

(golf) A cup-shaped object placed in the target hole.

‘The ball just misses the cup.’;

Capnoun

(slang) A bullet used to shoot someone.

Cupnoun

(in combination) Any of various sweetened alcoholic drinks.

‘cider cup; gin cup; claret cup’;

Capnoun

(soccer) An international appearance

‘Rio Ferdinand won his 50th cap for England in a game against Sweden.’;

Cupnoun

A rigid concave protective covering for the male genitalia. (for UK usage see box)

‘Players of contact sports are advised to wear a cup.’;

Capnoun

(obsolete) The top, or uppermost part; the chief.

Cupnoun

One of the two parts of a brassiere which each cover a breast, used as a measurement of size.

‘The cups are made of a particularly uncomfortable material.’;

Capnoun

(obsolete) A respectful uncovering of the head.

Cupnoun

(mathematics) The symbol $\cup$ denoting union and similar operations (confer cap).

Capnoun

(zoology) The whole top of the head of a bird from the base of the bill to the nape of the neck.

Cupnoun

A suit of the minor arcana in tarot, or one of the cards from the suit.

Capnoun

(architecture) The uppermost of any assemblage of parts.

‘the cap of column, door, etc.; a capital, coping, cornice, lintel, or plate’;

Cupnoun

(ultimate frisbee) A defensive style characterized by a three player near defense cupping the thrower; or those three players.

Capnoun

Something covering the top or end of a thing for protection or ornament.

Cupnoun

A flexible concave membrane used to temporarily attach a handle or hook to a flat surface by means of suction (suction cup).

Capnoun

(nautical) A collar of iron or wood used in joining spars, as the mast and the topmast, the bowsprit and the jib boom; also, a covering of tarred canvas at the end of a rope.

Cupnoun

Anything shaped like a cup.

‘the cup of an acorn’;

Capnoun

(geometry) A portion of a spherical or other convex surface.

Cupnoun

A cupping glass or other vessel or instrument used to produce the vacuum in cupping.

Capnoun

A large size of writing paper.

‘flat cap; foolscap; legal cap’;

Cupnoun

That which is to be received or indured; that which is allotted to one; a portion.

Capnoun

(finance) Capitalization.

Cupverb

(transitive) To form into the shape of a cup, particularly of the hands.

‘Cup your hands and I'll pour some rice into them.’;

Capnoun

(informal) An uppercase letter.

Cupverb

(transitive) To hold something in cupped hands.

‘He cupped the ball carefully in his hands.’;

Capnoun

(electronics) capacitor

‘Parasitic caps.’;

Cupverb

To supply with cups of wine.

Capnoun

(colloquial) A recording or screenshot.

‘Anyone have a cap of the games last night?’;

Cupverb

To apply a cupping apparatus to; to subject to the operation of cupping.

Capverb

(transitive) To cover or seal with a cap

Cupverb

To make concave or in the form of a cup.

‘to cup the end of a screw’;

Capverb

(transitive) To award a cap as a mark of distinction etc.

Cupnoun

A small vessel, used commonly to drink from; as, a tin cup, a silver cup, a wine cup; especially, in modern times, the pottery or porcelain vessel, commonly with a handle, used with a saucer in drinking tea, coffee, and the like.

Capverb

(transitive) To lie over or on top of something

Cupnoun

The contents of such a vessel; a cupful.

‘Give me a cup of sack, boy.’;

Capverb

(transitive) To surpass or outdo

Cupnoun

Repeated potations; social or excessive indulgence in intoxicating drinks; revelry.

‘Thence from cups to civil broils.’;

Capverb

(transitive) To set an upper limit on something

‘cap wages.’;

Cupnoun

That which is to be received or indured; that which is allotted to one; a portion.

‘O my Father, if it be possible, let this cup pass from me.’;

Capverb

(transitive) To make something even more wonderful at the end.

‘That really capped my day.’;

Cupnoun

Anything shaped like a cup; as, the cup of an acorn, or of a flower.

‘The cowslip's golden cup no more I see.’;

Capverb

To select a player to play for a specified side

Cupnoun

A cupping glass or other vessel or instrument used to produce the vacuum in cupping.

Capverb

To shoot (someone) with a firearm.

‘If he don't get outta my hood, I'm gonna cap his ass.’;

Cupverb

To supply with cups of wine.

‘Cup us, till the world go round.’;

Capverb

to select to play for the national team.

‘Peter Shilton is the most capped English footballer.’;

Cupverb

To apply a cupping apparatus to; to subject to the operation of cupping. See Cupping.

Capverb

Cupverb

To make concave or in the form of a cup; as, to cup the end of a screw.

Capverb

To deprive of a cap.

Cupnoun

a United States liquid unit equal to 8 fluid ounces

Capverb

To convert text to uppercase.

Cupnoun

the quantity a cup will hold;

‘he drank a cup of coffee’; ‘he borrowed a cup of sugar’;

Capverb

(transitive) To take a screenshot or to record a copy of a video.

Cupnoun

a small open container usually used for drinking; usually has a handle;

‘he put the cup back in the saucer’; ‘the handle of the cup was missing’;

Capnoun

Cupnoun

a large metal vessel with two handles that is awarded as a trophy to the winner of a competition;

‘the school kept the cups is a special glass case’;

Capnoun

The top, or uppermost part; the chief.

‘Thou art the cap of all the fools alive.’;

Cupnoun

any cup-shaped concavity;

‘bees filled the waxen cups with honey’; ‘he wore a jock strap with a metal cup’; ‘the cup of her bra’;

Capnoun

A respectful uncovering of the head.

‘He that will give a cap and make a leg in thanks.’;

Cupnoun

the hole (or metal container in the hole) on a golf green;

‘he swore as the ball rimmed the cup and rolled away’; ‘put the flag back in the cup’;

Capnoun

The whole top of the head of a bird from the base of the bill to the nape of the neck.

Cupnoun

a punch served in a pitcher instead of a punch bowl

Capnoun

Anything resembling a cap in form, position, or use

Cupnoun

cup-shaped plant organ

Capnoun

A large size of writing paper; as, flat cap; foolscap; legal cap.

Cupverb

form into the shape of a cup;

‘She cupped her hands’;

Capverb

To cover with a cap, or as with a cap; to provide with a cap or cover; to cover the top or end of; to place a cap upon the proper part of; as, to cap a post; to cap a gun.

‘The bones next the joint are capped with a smooth cartilaginous substance.’;

Cupverb

put into a cup;

‘cup the milk’;

Capverb

To deprive of cap.

Cupverb

treat by applying evacuated cups to the patient's skin

Capverb

To complete; to crown; to bring to the highest point or consummation; as, to cap the climax of absurdity.

Cupnoun

a small bowl-shaped container for drinking from, typically having a handle.

Capverb

To salute by removing the cap.

‘Tom . . . capped the proctor with the profoundest of bows.’;

Cupnoun

the contents of a cup

‘a cup of tea’;

Capverb

To match; to mate in contest; to furnish a complement to; as, to cap text; to cap proverbs.

‘Now I have him under girdle I'll cap verses with him to the end of the chapter.’;

Cupnoun

a measure of capacity used in cooking, equal to half a US pint (0.237 litre)

‘a cup of butter’;

Capverb

Cupnoun

(in church use) a chalice used at the Eucharist

‘Latin was replaced by the vernacular, and the cup was offered to the laity’;

Capnoun

Cupnoun

one of the suits in a tarot pack.

Capnoun

a top (as for a bottle)

Cupnoun

an ornamental trophy in the form of a cup, usually made of gold or silver and having a stem and two handles, awarded as a prize in a sports contest.

Capnoun

a mechanical or electrical explosive device or a small amount of explosive; can be used to initiate the reaction of a disrupting explosive

Cupnoun

a contest in which the winners are awarded a cup

‘playing in the Cup is the best thing ever’;

Capnoun

something serving as a cover or protection

Cupnoun

a cup-shaped thing.

Capnoun

a fruiting structure resembling an umbrella that forms the top of a stalked fleshy fungus such as a mushroom

Cupnoun

either of the two parts of a bra shaped to contain or support one breast

‘she had grown from an A to a C cup in just six months’;

Capnoun

an upper limit on what is allowed;

‘they established a cap for prices’;

Cupnoun

the hole on a putting green, or the metal container in it

‘the ball bounced out of the cup’;

Capnoun

dental appliance consisting of an artificial crown for a tooth

Cupnoun

a mixed drink made from fruit juices and typically containing wine or cider

‘the bars offered large glasses of white wine cup’; ‘a non-alcoholic fruit cup’;

Capnoun

the upper part of a column that supports the entablature

Cupverb

form (one's hand or hands) into the curved shape of a cup

‘‘Hey!’ Dad shouted, with his hands cupped around his mouth’;

Capverb

lie at the top of;

‘Snow capped the mountains’;

Cupverb

place the curved hand or hands around

‘he cupped her face in his hands’;

Capverb

restrict the number or amount of;

‘We had to cap the number of people we can accept into our club’;

Cupverb

bleed (someone) by using a glass in which a partial vacuum is formed by heating

‘Dr Ross ordered me to be cupped’;

Capnoun

a kind of soft, flat hat without a brim and typically with a peak

‘a man wearing a raincoat and a flat cap’; ‘her cap of dark hair’;

Cup

A cup is an open-top container used to hold liquids for pouring or drinking; while mainly used for drinking, it also can be used to store solids for pouring (e.g., sugar, flour, grains). Cups may be made of glass, metal, china, clay, wood, stone, polystyrene, plastic, aluminium or other materials, and are usually fixed with a stem, handles, or other adornments.

Capnoun

a kind of soft, close-fitting head covering worn for a particular purpose

‘a bathing cap’; ‘a shower cap’;

Capnoun

a cap awarded as a sign of membership of a particular sports team, especially a national team

‘he has won three caps for Scotland’;

Capnoun

a player to whom a cap is awarded

‘a former naval officer and rugby cap’;

Capnoun

‘school-leavers in cap and gown’;

Capnoun

the top of a bird's head when distinctively coloured.

Capnoun

a protective lid or cover for an object such as a bottle, the point of a pen, or a camera lens

‘a glass bottle with a screw cap’; ‘a lens cap from a camera’;

Capnoun

an artificial protective covering for a tooth.

Capnoun

an upper limit imposed on spending or borrowing

‘he raised the cap on local authority spending’;

Capnoun

a contraceptive diaphragm.

Capnoun

the broad upper part of the fruiting body of most mushrooms and toadstools, at the top of a stem and bearing gills or pores.

Capnoun

short for percussion cap

Capnoun

short for capitalization

‘small-cap stocks’; ‘mid-cap companies’;

Capverb

put a lid or cover on

‘he capped his pen’;

Capverb

form a covering layer or topmost part of

‘snow-capped mountains’;

Capverb

put an artificial protective covering on (a tooth)

‘his smile revealed perfectly capped teeth’;

Capverb

provide a fitting climax or conclusion to

‘he capped a memorable season by becoming champion of champions’;

Capverb

follow or reply to (a story, remark, or joke) by producing a better one

‘he prayed no wit would cap his remark with some repartee’;

Capverb

place a limit or restriction on (prices, expenditure, or borrowing)

‘council budgets will be capped’;

Capverb

be chosen as a member of a particular sports team, especially a national one

‘he was capped ten times by England’;

Capverb

confer a university degree on.

Cap

A cap is a kind of soft and flat headgear, usually with a visor. Caps have crowns that fit very close to the head.