Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 11fdd9a

Browse files
committed
Remove Range class due to conflict with .net 5.
1 parent bc2f0b5 commit 11fdd9a

File tree

8 files changed

+36
-311
lines changed

8 files changed

+36
-311
lines changed

src/TensorFlowNET.Core/Operations/Operation.Implicit.cs

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public static implicit operator IntPtr(Operation op)
3131
=> op._handle;
3232
public static implicit operator Tensor(Operation op)
3333
=> op.output;
34-
public static implicit operator RefVariable(Operation op)
35-
=> new RefVariable(op);
3634

3735
public override string ToString()
3836
{

src/TensorFlowNET.Core/Operations/embedding_ops.cs

-31
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,6 @@ namespace Tensorflow
2121
{
2222
public class embedding_ops
2323
{
24-
/// <summary>
25-
/// Helper function for embedding_lookup and _compute_sampled_logits.
26-
/// </summary>
27-
/// <param name="params"></param>
28-
/// <param name="ids"></param>
29-
/// <param name="partition_strategy"></param>
30-
/// <param name="name"></param>
31-
/// <returns></returns>
32-
public static Tensor _embedding_lookup_and_transform(RefVariable @params,
33-
Tensor ids,
34-
string partition_strategy = "mod",
35-
string name = null,
36-
string max_norm = null)
37-
{
38-
return tf_with(ops.name_scope(name, "embedding_lookup", new { @params, ids }), scope =>
39-
{
40-
name = scope;
41-
int np = 1;
42-
ids = ops.convert_to_tensor(ids, name: "ids");
43-
if (np == 1)
44-
{
45-
var gather = array_ops.gather(@params, ids, name: name);
46-
var result = _clip(gather, ids, max_norm);
47-
48-
return array_ops.identity(result);
49-
}
50-
51-
throw new NotImplementedException("_embedding_lookup_and_transform");
52-
});
53-
}
54-
5524
/// <summary>
5625
/// Helper function for embedding_lookup and _compute_sampled_logits.
5726
/// </summary>

src/TensorFlowNET.Keras/Engine/Model.Compile.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ public partial class Model
1010
LossesContainer compiled_loss;
1111
MetricsContainer compiled_metrics;
1212

13-
public void compile(ILossFunc loss, OptimizerV2 optimizer, string[] metrics)
13+
public void compile(OptimizerV2 optimizer = null,
14+
ILossFunc loss = null,
15+
string[] metrics = null)
1416
{
15-
this.optimizer = optimizer;
17+
this.optimizer = optimizer ?? new RMSprop(new RMSpropArgs
18+
{
19+
});
20+
21+
this.loss = loss ?? new MeanSquaredError();
22+
1623
compiled_loss = new LossesContainer(loss, output_names: output_names);
1724
compiled_metrics = new MetricsContainer(metrics, output_names: output_names);
1825

@@ -22,7 +29,6 @@ public void compile(ILossFunc loss, OptimizerV2 optimizer, string[] metrics)
2229
// Initialize cache attrs.
2330
_reset_compile_cache();
2431
_is_compiled = true;
25-
this.loss = loss;
2632
}
2733

2834
public void compile(string optimizer, string loss, string[] metrics)

src/TensorFlowNET.Keras/Layers/LayersApi.cs

+12
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,18 @@ public Tensors Input(TensorShape shape,
518518
return input_layer.InboundNodes[0].Outputs;
519519
}
520520

521+
public InputLayer InputLayer(TensorShape input_shape,
522+
string name = null,
523+
bool sparse = false,
524+
bool ragged = false)
525+
=> new InputLayer(new InputLayerArgs
526+
{
527+
InputShape = input_shape,
528+
Name = name,
529+
Sparse = sparse,
530+
Ragged = ragged
531+
});
532+
521533
/// <summary>
522534
/// Max pooling operation for 1D temporal data.
523535
/// </summary>

src/TensorFlowNet.Benchmarks/Tensorflow.Benchmark.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
<ItemGroup>
3838
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
39-
<PackageReference Include="SciSharp.TensorFlow.Redist-Windows-GPU" Version="2.3.1" />
39+
<PackageReference Include="SciSharp.TensorFlow.Redist-Windows-GPU" Version="2.5.0" />
4040
</ItemGroup>
4141

4242
<ItemGroup>

test/TensorFlowNET.Keras.UnitTest/Layers/LayersTest.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
22
using NumSharp;
3+
using System.Collections.Generic;
34
using Tensorflow;
4-
using Tensorflow.Operations.Initializers;
5+
using Tensorflow.Keras;
56
using static Tensorflow.Binding;
67
using static Tensorflow.KerasApi;
78

@@ -13,6 +14,18 @@ namespace TensorFlowNET.Keras.UnitTest
1314
[TestClass]
1415
public class LayersTest : EagerModeTestBase
1516
{
17+
// [TestMethod]
18+
public void InputLayer()
19+
{
20+
var model = keras.Sequential(new List<ILayer>
21+
{
22+
keras.layers.InputLayer(input_shape: 4),
23+
keras.layers.Dense(8)
24+
});
25+
model.compile(optimizer: keras.optimizers.RMSprop(0.001f));
26+
model.fit(np.zeros((10, 4)), np.ones((10, 8)));
27+
}
28+
1629
[TestMethod]
1730
public void Sequential()
1831
{

test/TensorFlowNET.Keras.UnitTest/Range.cs

-234
This file was deleted.

0 commit comments

Comments
 (0)