Skip to content

Fixed indentation and corrected warnings #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions lib/tensorflex.ex
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
defmodule Tensorflex do
@moduledoc """
A simple and fast library for running Tensorflow graph models in Elixir.
Tensorflex is written around the [Tensorflow C
API](https://www.tensorflow.org/install/install_c), and allows Elixir
developers to leverage Machine Learning and Deep Learning solutions in their
projects.
Tensorflex is written around the [Tensorflow C
API](https://www.tensorflow.org/install/install_c), and allows Elixir
developers to leverage Machine Learning and Deep Learning solutions in their
projects.

__NOTE__:

Expand All @@ -24,7 +24,7 @@ projects.
different tensor datatypes than the ones required by the graph can all lead to
failure. While these are not easy errors to make, do ensure that you test your
solution well before deployment.
"""
"""

alias Tensorflex.{NIFs, Graph, Tensor, Matrix}

Expand All @@ -41,7 +41,7 @@ projects.
Returns a tuple `{:ok, %Graph}`.

`%Graph` is an internal Tensorflex struct which holds the name of the graph
file and the binary definition data that is read in via the `.pb` file.
file and the binary definition data that is read in via the `.pb` file.

## Examples:

Expand Down Expand Up @@ -217,7 +217,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def get_graph_ops(%Graph{def: ref, name: filepath}) do
def get_graph_ops(%Graph{def: ref, name: _filepath}) do
NIFs.get_graph_ops(ref)
end

Expand Down Expand Up @@ -343,7 +343,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def matrix_pos(%Matrix{nrows: nrows, ncols: ncols, data: ref}, row, col) when row > 0 and col > 0 do
def matrix_pos(%Matrix{nrows: _nrows, ncols: _ncols, data: ref}, row, col) when row > 0 and col > 0 do
NIFs.matrix_pos(ref, row, col)
end

Expand All @@ -370,7 +370,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def size_of_matrix(%Matrix{nrows: nrows, ncols: ncols, data: ref}) do
def size_of_matrix(%Matrix{nrows: nrows, ncols: ncols, data: _ref}) do
{nrows, ncols}
end

Expand Down Expand Up @@ -453,7 +453,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def matrix_to_lists(%Matrix{nrows: nrows, ncols: ncols, data: ref}) do
def matrix_to_lists(%Matrix{nrows: _nrows, ncols: _ncols, data: ref}) do
NIFs.matrix_to_lists(ref)
end

Expand Down Expand Up @@ -495,7 +495,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def float64_tensor(%Matrix{nrows: val_rows, ncols: val_cols, data: val_ref}, %Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
def float64_tensor(%Matrix{nrows: _val_rows, ncols: _val_cols, data: val_ref}, %Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
{:ok, ref} = NIFs.float64_tensor(val_ref, dim_ref)
{:ok, %Tensor{datatype: :tf_double, tensor: ref}}
end
Expand Down Expand Up @@ -575,7 +575,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def float32_tensor(%Matrix{nrows: val_rows, ncols: val_cols, data: val_ref}, %Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
def float32_tensor(%Matrix{nrows: _val_rows, ncols: _val_cols, data: val_ref}, %Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
{:ok, ref} = NIFs.float32_tensor(val_ref, dim_ref)
{:ok, %Tensor{datatype: :tf_float, tensor: ref}}
end
Expand Down Expand Up @@ -659,7 +659,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def int32_tensor(%Matrix{nrows: val_rows, ncols: val_cols, data: val_ref}, %Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
def int32_tensor(%Matrix{nrows: _val_rows, ncols: _val_cols, data: val_ref}, %Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
{:ok, ref} = NIFs.int32_tensor(val_ref, dim_ref)
{:ok, %Tensor{datatype: :tf_int32, tensor: ref}}
end
Expand Down Expand Up @@ -769,7 +769,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def int32_tensor_alloc(%Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
def int32_tensor_alloc(%Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
{:ok, ref} = NIFs.int32_tensor_alloc(dim_ref)
{:ok, %Tensor{datatype: :tf_int32, tensor: ref}}
end
Expand Down Expand Up @@ -805,7 +805,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def float32_tensor_alloc(%Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
def float32_tensor_alloc(%Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
{:ok, ref} = NIFs.float32_tensor_alloc(dim_ref)
{:ok, %Tensor{datatype: :tf_float, tensor: ref}}
end
Expand Down Expand Up @@ -841,7 +841,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def float64_tensor_alloc(%Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
def float64_tensor_alloc(%Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
{:ok, ref} = NIFs.float64_tensor_alloc(dim_ref)
{:ok, %Tensor{datatype: :tf_double, tensor: ref}}
end
Expand Down Expand Up @@ -871,7 +871,7 @@ file and the binary definition data that is read in via the `.pb` file.
```
"""

def tensor_datatype(%Tensor{datatype: datatype, tensor: ref}) do
def tensor_datatype(%Tensor{datatype: datatype, tensor: _ref}) do
{:ok, datatype}
end

Expand All @@ -898,7 +898,7 @@ file and the binary definition data that is read in via the `.pb` file.
arguments. Support for grayscale images and other image formats such as `PNG`
will be added in the future.

## Examples
## Examples

To exemplify the working of the `load_image_as_tensor/1` function we will
cover the entire prediction pipeline for the Inception model. However, this
Expand Down Expand Up @@ -992,7 +992,7 @@ file and the binary definition data that is read in via the `.pb` file.
panda, panda, panda bear, coon bear, Ailuropoda melanoleuca` (Line 3691 in the
file). Thus, we have correctly identified the animal in the image as a panda
using Tensorflex.
"""
"""

def load_image_as_tensor(imagepath) do
unless File.exists?(imagepath) do
Expand Down Expand Up @@ -1182,9 +1182,9 @@ file and the binary definition data that is read in via the `.pb` file.

* Working with an RNN-LSTM example for sentiment analysis is covered
[here](https://github.com/anshuman23/tensorflex/pull/25).
"""
"""

def run_session(%Graph{def: graphdef, name: filepath}, %Tensor{datatype: input_datatype, tensor: input_ref}, %Tensor{datatype: output_datatype, tensor: output_ref}, input_opname, output_opname) do
def run_session(%Graph{def: graphdef, name: _filepath}, %Tensor{datatype: _input_datatype, tensor: input_ref}, %Tensor{datatype: _output_datatype, tensor: output_ref}, input_opname, output_opname) do
NIFs.run_session(graphdef, input_ref, output_ref, input_opname, output_opname)
end

Expand Down
10 changes: 5 additions & 5 deletions test/tensorflex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ defmodule TensorflexTest do

describe "graph loading and reading functionalities" do
test "graph loading check" do
{:ok, graph_toy} = Tensorflex.read_graph "./test/graphdef_toy.pb"
{:ok, graph_iris} = Tensorflex.read_graph "./test/graphdef_iris.pb"
{:ok, _graph_toy} = Tensorflex.read_graph "./test/graphdef_toy.pb"
{:ok, _graph_iris} = Tensorflex.read_graph "./test/graphdef_iris.pb"
end

test "get all graph ops" do
Expand All @@ -151,11 +151,11 @@ defmodule TensorflexTest do

test "incorrect usage check" do
assert_raise ArgumentError, fn ->
{:ok, graph} = Tensorflex.read_graph "Makefile"
{:ok, _graph} = Tensorflex.read_graph "Makefile"
end

assert_raise ArgumentError, fn ->
{:ok, graph} = Tensorflex.read_graph "Makefile.pb"
{:ok, _graph} = Tensorflex.read_graph "Makefile.pb"
end
end
end
Expand Down Expand Up @@ -185,7 +185,7 @@ defmodule TensorflexTest do

test "CSV-to-matrix function incorrect usage check" do
assert_raise ArgumentError, fn ->
m = Tensorflex.load_csv_as_matrix("./test/sample1.csv", header: :no_header, delimiter: ",")
_m = Tensorflex.load_csv_as_matrix("./test/sample1.csv", header: :no_header, delimiter: ",")
end
end
end
Expand Down