Skip to content

Commit

Permalink
update docs (#1062)
Browse files Browse the repository at this point in the history
* Update tensor.md

* Update maths.md

* Update tester.md

* Update timer.md

* Update random.md

* Update random.md

* Update file.md

* revert random.md

* Update pipefile.md
  • Loading branch information
lambdawill authored and soumith committed Jul 20, 2017
1 parent 1aba999 commit aed3171
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 49 deletions.
14 changes: 7 additions & 7 deletions doc/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ Serializable objects are `Torch` objects having a `read()` and

If the object to save contains several other objects (let say it is a tree
of objects), then objects appearing several times in this tree will be
_saved only once_. This saves disk space, speedup loading/saving and
respect the dependencies between objects.
_saved only once_. This saves disk space, speeds up loading/saving and
respects the dependencies between objects.

Interestingly, if the `File` is a [MemoryFile](memoryfile.md), it allows
the user to easily make a _clone_ of any serializable object:
Expand Down Expand Up @@ -188,22 +188,22 @@ If the object has been already written in the file, only a _reference_ to
this already saved object will be written: this saves space an speed-up
writing; it also allows to keep the dependencies between objects intact.

In returns, if one writes an object, modify its member, and write the
In returns, if one writes an object, modifies its member, and writes the
object again in the same file, the modifications will not be recorded
in the file, as only a reference to the original will be written. See
[readObject()](#torch.File.readObject) for an example.

<a name="torch.File.readString"></a>
### [string] readString(format) ###

If `format` starts with ''"*l"` then returns the next line in the `File''. The end-of-line character is skipped.
If `format` starts with `"*l"` then returns the next line in the `File`. The end-of-line character is skipped.

If `format` starts with ''"*a"` then returns all the remaining contents of the `File''.
If `format` starts with `"*a"` then returns all the remaining contents of the `File`.

If no data is available, then an error is raised, except if `File` is in [quiet()](#torch.File.quiet) mode where
it then returns an empty string `''` and after that you'll be able to see that last reading failed due to end of file with your_file:[hasError()](#torch.File.hasError).

Because Torch is more precise on number typing, the `Lua` format ''"*n"'' is not supported:
Because Torch is more precise on number typing, the `Lua` format `"*n"` is not supported:
instead use one of the [number read methods](#torch.File.read).

<a name="torch.File.writeString"></a>
Expand Down Expand Up @@ -361,4 +361,4 @@ behaviour.
<a name="torch.File.isReferenced"></a>
### isReferenced() ###

Return the state set by [referenced](#torch.File.referenced).
Returns the state set by [referenced](#torch.File.referenced).
26 changes: 13 additions & 13 deletions doc/maths.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ By default the elements are sorted into 100 equally spaced bins between the mini
`y = torch.bhistc(x, n, min, max)` same as above with `n` bins and `[min, max]` as elements range.

```lua
x =torch.Tensor(3, 6)
x = torch.Tensor(3, 6)

> x[1] = torch.Tensor{ 2, 4, 2, 2, 5, 4 }
> x[2] = torch.Tensor{ 3, 5, 1, 5, 3, 5 }
Expand Down Expand Up @@ -267,40 +267,40 @@ The sampling is done through a technique defined in a very simple way in this bl
The `output` `Tensor` that is fed into the `multinomialAlias` method need not be contiguous. The `output` tensor can only be a 1d tensor. If you are required to fill a nd tensor enter a 1d view of the same tensor. This method is exceptionally faster than `torch.multinomial` when you want to sample a lot of samples from the same distrbution or sample from the same distribution a large number of times. `torch.multinomial` is faster for sampling few samples from a distribution once because the `multinomialAliasSetup` method takes some time in this case. To see and compare how these two methods differ in speed run `th test/test_aliasMultinomial.lua`.

```lua
th> state = torch.multinomialAliasSetup(probs)
th> state
> state = torch.multinomialAliasSetup(probs)
> state
{
1 : LongTensor - size: 4
2 : DoubleTensor - size: 4
}
th> output = torch.LongTensor(2,3)
th> torch.multinomialAlias(output:view(-1), state)
> output = torch.LongTensor(2,3)
> torch.multinomialAlias(output:view(-1), state)
4
1
2
3
2
2
[torch.LongTensor of size 6]
th> output
> output
4 1 2
3 2 2
[torch.LongTensor of size 2x3]
```

You can also allocate memory and reuse it for the state table.

```
th> state = {torch.LongTensor(), torch.DoubleTensor()}
th> probs = torch.DoubleTensor({0.2, 0.3, 0.5})
th> state = torch.multinomialAliasSetup(probs, state)
th> state
```lua
> state = {torch.LongTensor(), torch.DoubleTensor()}
> probs = torch.DoubleTensor({0.2, 0.3, 0.5})
> state = torch.multinomialAliasSetup(probs, state)
> state
{
1 : LongTensor - size: 3
2 : DoubleTensor - size: 3
}
th> output = torch.LongTensor(7)
th> torch.multinomialAlias(output, state)
> output = torch.LongTensor(7)
> torch.multinomialAlias(output, state)
2
2
3
Expand Down
4 changes: 2 additions & 2 deletions doc/pipefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ given to the [torch.PipeFile(fileName, mode)](#torch.PipeFile). Read-write mode
<a name="torch.PipeFile"></a>
### torch.PipeFile(command, [mode], [quiet]) ###

_Constructor_ which execute `command` by opening a pipe in read or write
`mode`. Valid `mode` are `"r"` (read) or `"w"` (write). Default is read
_Constructor_ which executes `command` by opening a pipe in read or write
`mode`. Valid `mode`s are `"r"` (read) or `"w"` (write). Default is read
mode.

If (and only if) `quiet` is `true`, no error will be raised in case of
Expand Down
4 changes: 2 additions & 2 deletions doc/random.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ random numbers is produced.

<a name="torch.setRNGState"></a>
### [Tensor] setRNGState([gen,] state) ###
Set the state of the random number generator. If `state` was obtained earlier
Sets the state of the random number generator. If `state` was obtained earlier
using `getRNGState` then the random number generator should now generate the
same numbers as it did from the point where `state` was obtained. This function
returns its argument, `state`.
returns its argument `state`.

<a name="torch.random"></a>
### [number] random([gen,] [a], [b]) ###
Expand Down
2 changes: 1 addition & 1 deletion doc/tensor.md
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ for i=1,7 do x[i] = i end

These functions apply a function to each element of the tensor on which called the
method (self). These methods are much faster than using a `for`
loop in `Lua`. The results is stored in `self` (if the function returns
loop in `Lua`. The results are stored in `self` (if the function returns
something).

<a name="torch.Tensor.apply"></a>
Expand Down
42 changes: 21 additions & 21 deletions doc/tester.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Returns a new instance of `torch.Tester` class.
<a name="torch.Tester.add"></a>
### add(f, 'name') ###

Add `f`, either a test function or a table of test functions, to the tester.
Adds `f`, either a test function or a table of test functions, to the tester.

If `f` is a function then names should be unique. There are a couple of special
values for `name`: if it is `_setUp` or `_tearDown`, then the function will be
Expand All @@ -105,7 +105,7 @@ Returns the torch.Tester instance.
<a name="torch.Tester.run"></a>
### run(testNames) ###

Run tests that have been added by [add(f, 'name')](#torch.Tester.add).
Runs tests that have been added by [add(f, 'name')](#torch.Tester.add).
While running it reports progress, and at the end gives a summary of all errors.

If a list of names `testNames` is passed, then all tests matching these names
Expand All @@ -120,7 +120,7 @@ tester:run({"test2", "test3"}) -- runs the tests named "test2" and "test3"
<a name="torch.Tester.disable"></a>
### disable(testNames) ###

Prevent the given tests from running, where `testNames` can be a single string
Prevents the given tests from running, where `testNames` can be a single string
or list of strings. More precisely, when [run](#torch.Tester.run)
is invoked, it will skip these tests, while still printing out an indication of
skipped tests. This is useful for temporarily disabling tests without
Expand Down Expand Up @@ -149,7 +149,7 @@ Completed 0 asserts in 1 test with 0 failures and 0 errors and 1 disabled
<a name="torch.Tester.assert"></a>
### assert(condition [, message]) ###

Check that `condition` is true (using the optional `message` if the test
Checks that `condition` is true (using the optional `message` if the test
fails).
Returns whether the test passed.

Expand All @@ -159,7 +159,7 @@ Returns whether the test passed.
General equality check between numbers, tables, strings, `torch.Tensor`
objects, `torch.Storage` objects, etc.

Check that `got` and `expected` have the same contents, where tables are
Checks that `got` and `expected` have the same contents, where tables are
compared recursively, tensors and storages are compared elementwise, and numbers
are compared within `tolerance` (default value `0`). Other types are compared by
strict equality. The optional `message` is used if the test fails.
Expand All @@ -177,7 +177,7 @@ Convenience function; does the same as
General inequality check between numbers, tables, strings, `torch.Tensor`
objects, `torch.Storage` objects, etc.

Check that `got` and `unexpected` have different contents, where tables are
Checks that `got` and `unexpected` have different contents, where tables are
compared recursively, tensors and storages are compared elementwise, and numbers
are compared within `tolerance` (default value `0`). Other types are compared by
strict equality. The optional `message` is used if the test fails.
Expand All @@ -192,35 +192,35 @@ Convenience function; does the same as
<a name="torch.Tester.assertlt"></a>
### assertlt(a, b [, message]) ###

Check that `a < b` (using the optional `message` if the test fails),
Checks that `a < b` (using the optional `message` if the test fails),
where `a` and `b` are numbers.
Returns whether the test passed.

<a name="torch.Tester.assertgt"></a>
### assertgt(a, b [, message]) ###

Check that `a > b` (using the optional `message` if the test fails),
Checks that `a > b` (using the optional `message` if the test fails),
where `a` and `b` are numbers.
Returns whether the test passed.

<a name="torch.Tester.assertle"></a>
### assertle(a, b [, message]) ###

Check that `a <= b` (using the optional `message` if the test fails),
Checks that `a <= b` (using the optional `message` if the test fails),
where `a` and `b` are numbers.
Returns whether the test passed.

<a name="torch.Tester.assertge"></a>
### assertge(a, b [, message]) ###

Check that `a >= b` (using the optional `message` if the test fails),
Checks that `a >= b` (using the optional `message` if the test fails),
where `a` and `b` are numbers.
Returns whether the test passed.

<a name="torch.Tester.asserteq"></a>
### asserteq(a, b [, message]) ###

Check that `a == b` (using the optional `message` if the test fails).
Checks that `a == b` (using the optional `message` if the test fails).
Note that this uses the generic lua equality check, so objects such as tensors
that have the same content but are distinct objects will fail this test;
consider using [assertGeneralEq()](#torch.Tester.assertGeneralEq) instead.
Expand All @@ -229,7 +229,7 @@ Returns whether the test passed.
<a name="torch.Tester.assertne"></a>
### assertne(a, b [, message]) ###

Check that `a ~= b` (using the optional `message` if the test fails).
Checks that `a ~= b` (using the optional `message` if the test fails).
Note that this uses the generic lua inequality check, so objects such as tensors
that have the same content but are distinct objects will pass this test;
consider using [assertGeneralNe()](#torch.Tester.assertGeneralNe) instead.
Expand All @@ -238,15 +238,15 @@ Returns whether the test passed.
<a name="torch.Tester.assertalmosteq"></a>
### assertalmosteq(a, b [, tolerance] [, message]) ###

Check that `|a - b| <= tolerance` (using the optional `message` if the
Checks that `|a - b| <= tolerance` (using the optional `message` if the
test fails), where `a` and `b` are numbers, and `tolerance` is an optional
number (default `1e-16`).
Returns whether the test passed.

<a name="torch.Tester.assertTensorEq"></a>
### assertTensorEq(ta, tb [, tolerance] [, message]) ###

Check that `max(abs(ta - tb)) <= tolerance` (using the optional `message`
Checks that `max(abs(ta - tb)) <= tolerance` (using the optional `message`
if the test fails), where `ta` and `tb` are tensors, and `tolerance` is an
optional number (default `1e-16`). Tensors that are different types or sizes
will cause this check to fail.
Expand All @@ -255,7 +255,7 @@ Returns whether the test passed.
<a name="torch.Tester.assertTensorNe"></a>
### assertTensorNe(ta, tb [, tolerance] [, message]) ###

Check that `max(abs(ta - tb)) > tolerance` (using the optional `message`
Checks that `max(abs(ta - tb)) > tolerance` (using the optional `message`
if the test fails), where `ta` and `tb` are tensors, and `tolerance` is an
optional number (default `1e-16`). Tensors that are different types or sizes
will cause this check to pass.
Expand All @@ -264,23 +264,23 @@ Returns whether the test passed.
<a name="torch.Tester.assertTableEq"></a>
### assertTableEq(ta, tb [, tolerance] [, message]) ###

Check that the two tables have the same contents, comparing them
Checks that the two tables have the same contents, comparing them
recursively, where objects such as tensors are compared using their contents.
Numbers (such as those appearing in tensors) are considered equal if
their difference is at most the given tolerance.

<a name="torch.Tester.assertTableNe"></a>
### assertTableNe(ta, tb [, tolerance] [, message]) ###

Check that the two tables have distinct contents, comparing them
Checks that the two tables have distinct contents, comparing them
recursively, where objects such as tensors are compared using their contents.
Numbers (such as those appearing in tensors) are considered equal if
their difference is at most the given tolerance.

<a name="torch.Tester.assertError"></a>
### assertError(f [, message]) ###

Check that calling `f()` (via `pcall`) raises an error (using the
Checks that calling `f()` (via `pcall`) raises an error (using the
optional `message` if the test fails).
Returns whether the test passed.

Expand All @@ -294,22 +294,22 @@ Returns whether the test passed.
<a name="torch.Tester.assertErrorMsg"></a>
### assertErrorMsg(f, errmsg [, message]) ###

Check that calling `f()` (via `pcall`) raises an error with the specific error
Checks that calling `f()` (via `pcall`) raises an error with the specific error
message `errmsg` (using the optional `message` if the test fails).
Returns whether the test passed.

<a name="torch.Tester.assertErrorPattern"></a>
### assertErrorPattern(f, errPattern [, message]) ###

Check that calling `f()` (via `pcall`) raises an error matching `errPattern`
Checks that calling `f()` (via `pcall`) raises an error matching `errPattern`
(using the optional `message` if the test fails).
The matching is done using `string.find`; in particular substrings will match.
Returns whether the test passed.

<a name="torch.Tester.assertErrorObj"></a>
### assertErrorObj(f, errcomp [, message]) ###

Check that calling `f()` (via `pcall`) raises an error object `err` such that
Checks that calling `f()` (via `pcall`) raises an error object `err` such that
calling `errcomp(err)` returns true (using the optional `message` if the test
fails).
Returns whether the test passed.
Expand Down
6 changes: 3 additions & 3 deletions doc/timer.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ Returns a new `Timer`. The timer starts to count the time now.
<a name="torch.Timer.reset"></a>
### [self] reset() ###

Reset the timer accumulated time to `0`. If the timer was running, the timer
Resets the timer accumulated time to `0`. If the timer was running, the timer
restarts to count the time now. If the timer was stopped, it stays stopped.

<a name="torch.Timer.resume"></a>
### [self] resume() ###

Resume a stopped timer. The timer restarts to count the time, and addition
Resumes a stopped timer. The timer restarts to count the time, and addition
the accumulated time with the time already counted before being stopped.

<a name="torch.Timer.stop"></a>
### [self] stop() ###

Stop the timer. The accumulated time counted until now is stored.
Stops the timer. The accumulated time counted until now is stored.

<a name="torch.Timer.time"></a>
### [table] time() ###
Expand Down

0 comments on commit aed3171

Please sign in to comment.