Skip to content

Commit 984405f

Browse files
committed
2 parents d5d5a46 + d2e7078 commit 984405f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1607
-636
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ Example runner will download all the required files like training data and model
150150
* [Named Entity Recognition](test/TensorFlowNET.Examples/TextProcess/NER)
151151
* [Transfer Learning for Image Classification in InceptionV3](test/TensorFlowNET.Examples/ImageProcess/RetrainImageClassifier.cs)
152152

153+
More troubleshooting of running example refer [here](tensorflowlib/README.md).
154+
153155
### Contribute:
154156

155157
Feel like contributing to one of the hottest projects in the Machine Learning field? Want to know how Tensorflow magically creates the computational graph? We appreciate every contribution however small. There are tasks for novices to experts alike, if everyone tackles only a small task the sum of contributions will be huge.

docs/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-cayman

graph/InceptionV3.meta

-11.8 KB
Binary file not shown.

src/TensorFlowNET.Core/APIs/tf.array.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ public static Tensor concat(IList<Tensor> values, int axis, string name = "conca
3636
public static Tensor expand_dims(Tensor input, int axis = -1, string name = null, int dim = -1)
3737
=> array_ops.expand_dims(input, axis, name, dim);
3838

39+
/// <summary>
40+
/// Creates a tensor filled with a scalar value.
41+
/// </summary>
42+
/// <param name="dims"></param>
43+
/// <param name="value"></param>
44+
/// <param name="name"></param>
45+
/// <returns></returns>
46+
public static Tensor fill<T>(Tensor dims, T value, string name = null)
47+
=> gen_array_ops.fill(dims, value, name: name);
48+
3949
/// <summary>
4050
/// Return the elements, either from `x` or `y`, depending on the `condition`.
4151
/// </summary>

src/TensorFlowNET.Core/APIs/tf.gradients.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Tensorflow
66
{
77
public static partial class tf
88
{
9-
public static object gradients(Tensor[] ys,
9+
public static Tensor[] gradients(Tensor[] ys,
1010
Tensor[] xs,
1111
Tensor[] grad_ys = null,
1212
string name = "gradients",
@@ -15,7 +15,7 @@ public static object gradients(Tensor[] ys,
1515
int? aggregation_method = null,
1616
Tensor[] stop_gradients = null)
1717
{
18-
return gradients_impl._GradientsHelper(ys,
18+
return gradients_util._GradientsHelper(ys,
1919
xs,
2020
grad_ys,
2121
name,
@@ -33,13 +33,31 @@ public static Tensor[] gradients(Tensor ys,
3333
int? aggregation_method = null,
3434
Tensor[] stop_gradients = null)
3535
{
36-
return gradients_impl._GradientsHelper(new Tensor[] { ys },
36+
return gradients_util._GradientsHelper(new Tensor[] { ys },
3737
xs,
3838
grad_ys,
3939
name,
4040
colocate_gradients_with_ops,
4141
gate_gradients,
4242
stop_gradients: stop_gradients);
4343
}
44+
45+
public static Tensor[] gradients(Tensor ys,
46+
Tensor xs,
47+
Tensor[] grad_ys = null,
48+
string name = "gradients",
49+
bool colocate_gradients_with_ops = false,
50+
bool gate_gradients = false,
51+
int? aggregation_method = null,
52+
Tensor[] stop_gradients = null)
53+
{
54+
return gradients_util._GradientsHelper(new Tensor[] { ys },
55+
new Tensor[] { xs },
56+
grad_ys,
57+
name,
58+
colocate_gradients_with_ops,
59+
gate_gradients,
60+
stop_gradients: stop_gradients);
61+
}
4462
}
4563
}

src/TensorFlowNET.Core/APIs/tf.layers.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public static Tensor dense(Tensor inputs,
142142

143143
var layer = new Dense(units, activation,
144144
use_bias: use_bias,
145+
bias_initializer: bias_initializer,
145146
kernel_initializer: kernel_initializer);
146147

147148
return layer.apply(inputs);

src/TensorFlowNET.Core/APIs/tf.math.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ public static Tensor multiply<Tx, Ty>(Tx x, Ty y)
257257
public static Tensor negative(Tensor x, string name = null)
258258
=> gen_math_ops.neg(x, name);
259259

260+
/// <summary>
261+
/// Divides x / y elementwise (using Python 2 division operator semantics).
262+
/// </summary>
263+
/// <param name="x"></param>
264+
/// <param name="y"></param>
265+
/// <param name="name"></param>
266+
/// <returns></returns>
267+
public static Tensor div(Tensor x, Tensor y, string name = null)
268+
=> math_ops.div(x, y, name: name);
269+
260270
public static Tensor divide<T>(Tensor x, T[] y, string name = null) where T : struct
261271
=> x / ops.convert_to_tensor(y, dtype: x.dtype.as_base_dtype(), name: "y");
262272

src/TensorFlowNET.Core/APIs/tf.variable.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public static RefVariable get_variable(string name,
2323
TF_DataType dtype = TF_DataType.DtInvalid,
2424
object initializer = null, // IInitializer or Tensor
2525
bool? trainable = null,
26+
bool? use_resource = null,
27+
bool validate_shape = true,
2628
VariableSynchronization synchronization = VariableSynchronization.Auto,
2729
VariableAggregation aggregation = VariableAggregation.None)
2830
{
@@ -32,6 +34,8 @@ public static RefVariable get_variable(string name,
3234
name,
3335
shape: shape,
3436
dtype: dtype,
37+
use_resource: use_resource,
38+
validate_shape: validate_shape,
3539
initializer: initializer,
3640
trainable: trainable);
3741
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Framework
6+
{
7+
/// <summary>
8+
/// Abstract base class for Tensor-like objects that are composed from Tensors.
9+
/// </summary>
10+
public abstract class CompositeTensor
11+
{
12+
}
13+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Framework
6+
{
7+
/// <summary>
8+
/// A sparse representation of a set of tensor slices at given indices.
9+
/// </summary>
10+
public class IndexedSlices : CompositeTensor
11+
{
12+
Tensor _values;
13+
public Tensor values => _values;
14+
Tensor _indices;
15+
public Tensor indices => _indices;
16+
Tensor _dense_shape;
17+
public Tensor dense_shape => _dense_shape;
18+
19+
public string name => _values.name;
20+
21+
public string device => _values.Device;
22+
23+
public Operation op => _values.op;
24+
25+
public TF_DataType dtype => _values.dtype;
26+
27+
public Graph graph => _values.graph;
28+
29+
public IndexedSlices(Tensor values, Tensor indices, Tensor dense_shape = null)
30+
{
31+
_values = values;
32+
_indices = indices;
33+
_dense_shape = dense_shape;
34+
35+
_values.Tag = this;
36+
}
37+
38+
public static implicit operator Tensor(IndexedSlices indexedSlices)
39+
{
40+
return indexedSlices.values;
41+
}
42+
43+
public static implicit operator IndexedSlices(Tensor tensor)
44+
{
45+
return tensor.Tag as IndexedSlices;
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)