Skip to content

Commit e748a8f

Browse files
committed
overload ndarray == operator
1 parent 135562e commit e748a8f

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/TensorFlowNET.Core/NumPy/NDArray.Operators.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ public partial class NDArray
2222
public static NDArray operator <(NDArray lhs, NDArray rhs) => new NDArray(gen_math_ops.less(lhs, rhs));
2323
[AutoNumPy]
2424
public static NDArray operator -(NDArray lhs) => new NDArray(gen_math_ops.neg(lhs));
25+
[AutoNumPy]
26+
public static bool operator ==(NDArray lhs, NDArray rhs) => rhs is null ? false : (bool)math_ops.equal(lhs, rhs);
27+
public static bool operator !=(NDArray lhs, NDArray rhs) => !(lhs == rhs);
2528
}
2629
}

src/TensorFlowNET.Core/Numpy/Numpy.Creation.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,16 @@ public static NDArray linspace<T>(T start, T stop, int num = 50, bool endpoint =
6262
[AutoNumPy]
6363
public static NDArray load(string file) => tf.numpy.load(file);
6464

65+
public static T Load<T>(string path)
66+
where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
67+
{
68+
using (var stream = new FileStream(path, FileMode.Open))
69+
return Load<T>(stream);
70+
}
71+
6572
[AutoNumPy]
6673
public static T Load<T>(Stream stream)
67-
where T : class,
68-
ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
74+
where T : class, ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
6975
=> tf.numpy.Load<T>(stream);
7076

7177
[AutoNumPy]

src/TensorFlowNET.Core/Training/Saving/Saver.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ public string save(Session sess,
211211
export_meta_graph(meta_graph_filename, strip_default_attrs: strip_default_attrs, save_debug_info: save_debug_info);
212212
}
213213

214-
return _is_empty ? string.Empty : model_checkpoint_path[0].StringData()[0];
214+
return checkpoint_file;
215+
//var x = model_checkpoint_path[0];
216+
//var str = x.StringData();
217+
//return _is_empty ? string.Empty : model_checkpoint_path[0].StringData()[0];
215218
}
216219

217220
public (Saver, object) import_meta_graph(string meta_graph_or_file,

0 commit comments

Comments
 (0)