Skip to content

Commit 2860139

Browse files
committed
Remove Range due to confilict.
1 parent ad6ad84 commit 2860139

File tree

11 files changed

+87
-51
lines changed

11 files changed

+87
-51
lines changed

src/TensorFlowNET.Core/Tensors/Tensor.Index.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ public Tensor this[params Slice[] slices]
6060
}
6161
}
6262

63-
public Tensor this[Range slices]
64-
=> throw new NotImplementedException("");
65-
6663
public Tensor this[params string[] slices]
6764
=> this[slices.Select(x => new Slice(x)).ToArray()];
6865

69-
7066
public Tensor slice(Slice slice)
7167
{
7268
var slice_spec = new int[] { slice.Start.Value };
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Keras.Utils
6+
{
7+
public class KerasUtils
8+
{
9+
/// <summary>
10+
/// Downloads a file from a URL if it not already in the cache.
11+
/// </summary>
12+
/// <param name="fname">Name of the file</param>
13+
/// <param name="origin">Original URL of the file</param>
14+
/// <param name="untar"></param>
15+
/// <param name="md5_hash"></param>
16+
/// <param name="file_hash"></param>
17+
/// <param name="cache_subdir"></param>
18+
/// <param name="hash_algorithm"></param>
19+
/// <param name="extract"></param>
20+
/// <param name="archive_format"></param>
21+
/// <param name="cache_dir"></param>
22+
/// <returns></returns>
23+
public string get_file(string fname, string origin,
24+
bool untar = false,
25+
string md5_hash = null,
26+
string file_hash = null,
27+
string cache_subdir = "datasets",
28+
string hash_algorithm = "auto",
29+
bool extract = false,
30+
string archive_format = "auto",
31+
string cache_dir = null)
32+
=> data_utils.get_file(fname, origin,
33+
untar: untar,
34+
md5_hash: md5_hash,
35+
file_hash: file_hash,
36+
cache_subdir: cache_subdir,
37+
hash_algorithm: hash_algorithm,
38+
extract: extract,
39+
archive_format: archive_format,
40+
cache_dir: cache_dir);
41+
}
42+
}

src/TensorFlowNET.Keras/Utils/RuntimeHelpers.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Linq;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Text;
6+
7+
namespace Tensorflow.Keras.Utils
8+
{
9+
public class data_utils
10+
{
11+
public static string get_file(string fname, string origin,
12+
bool untar = false,
13+
string md5_hash = null,
14+
string file_hash = null,
15+
string cache_subdir = "datasets",
16+
string hash_algorithm = "auto",
17+
bool extract = false,
18+
string archive_format = "auto",
19+
string cache_dir = null)
20+
{
21+
var datadir_base = cache_dir;
22+
Directory.CreateDirectory(datadir_base);
23+
24+
var datadir = Path.Combine(datadir_base, cache_subdir);
25+
Directory.CreateDirectory(datadir);
26+
27+
Web.Download(origin, datadir, fname);
28+
29+
if (untar)
30+
Compress.ExtractTGZ(Path.Combine(datadir_base, fname), datadir_base);
31+
else if (extract)
32+
Compress.ExtractGZip(Path.Combine(datadir_base, fname), datadir_base);
33+
34+
return datadir;
35+
}
36+
}
37+
}

src/TensorFlowNET.Keras/Utils/layer_utils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static void print_summary(Model model, int line_length = -1, float[] posi
6767
line_length = 65;
6868
if (positions == null)
6969
positions = new[] { 0.45f, 0.85f, 1.0f };
70-
if (positions[^1] <= 1)
70+
if (positions.Last() <= 1)
7171
positions = positions.Select(p => line_length * p).ToArray();
7272
to_display = new[] { "Layer (type)", "Output Shape", "Param #" };
7373
}
@@ -77,7 +77,7 @@ public static void print_summary(Model model, int line_length = -1, float[] posi
7777
line_length = 98;
7878
if (positions == null)
7979
positions = new[] { 0.33f, 0.55f, 0.67f, 1.0f };
80-
if (positions[^1] <= 1)
80+
if (positions.Last() <= 1)
8181
positions = positions.Select(p => line_length * p).ToArray();
8282
to_display = new[] { "Layer (type)", "Output Shape", "Param #", "Connected to" };
8383

@@ -118,7 +118,7 @@ static void print_row(string[] fields, int[] positions)
118118
foreach (var i in range(fields.Length))
119119
{
120120
if (i > 0)
121-
line = line[0..^1] + " ";
121+
line = line + " ";
122122
line += fields[i];
123123
line = string.Join("", line.Take(positions[i]));
124124
line += string.Join("", range(positions[i] - len(line)).Select(x => " "));
File renamed without changes.

test/TensorFlowNET.Keras.UnitTest/Tensorflow.Keras.UnitTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77

test/TensorFlowNET.Native.UnitTest/Tensorflow.Native.UnitTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77

test/TensorFlowNET.UnitTest/Dataset/DatasetTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void Map()
119119
long value = 0;
120120

121121
var dataset = tf.data.Dataset.range(0, 2);
122-
dataset = dataset.map(x => x + 10);
122+
dataset = dataset.map(x => x[0] + 10);
123123

124124
foreach (var item in dataset)
125125
{
@@ -147,7 +147,7 @@ public void Cache()
147147
public void Cardinality()
148148
{
149149
var dataset = tf.data.Dataset.range(10);
150-
dataset = dataset.map(x => x + 1);
150+
dataset = dataset.map(x => x[0] + 1);
151151
var cardinality = dataset.dataset_cardinality();
152152
Assert.AreEqual(new long[] { 10 }, cardinality.numpy());
153153
}

0 commit comments

Comments
 (0)