Browse Source

fix rot90_3d

tags/v0.20
carb0n Haiping 5 years ago
parent
commit
cd43400e98
2 changed files with 48 additions and 9 deletions
  1. +42
    -1
      src/TensorFlowNET.Core/Operations/control_flow_ops.cs
  2. +6
    -8
      src/TensorFlowNET.Core/Operations/image_ops_impl.cs

+ 42
- 1
src/TensorFlowNET.Core/Operations/control_flow_ops.cs View File

@@ -1,4 +1,4 @@
/*****************************************************************************
/*****************************************************************************
Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved. Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.


Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
@@ -226,6 +226,47 @@ namespace Tensorflow
}); });
} }


internal static Tensor _case_helper(Func<Tensor, Tensor> cond_fn, Tensor[] pred_fn_pairs, Func<Tensor[]> callable_default, bool exclusive, string name,
bool allow_python_preds = false)
{
/*
(Tensor[] predicates, Tensor[] actions) = _case_verify_and_canonicalize_args(
pred_fn_pairs, exclusive, name, allow_python_preds);
return tf_with(ops.name_scope(name, "case", new [] {predicates}), delegate
{
if (callable_default == null)
{
(callable_default, predicates, actions) = _case_create_default_action(
predicates, actions);
}
var fn = callable_default;
});
*/

throw new NotImplementedException("_case_helper");
}

internal static (Func<Tensor[]>, Tensor[], Tensor[]) _case_create_default_action(Tensor[] predicates, Tensor[] actions)
{
throw new NotImplementedException("_case_create_default_action");
}

internal static (Tensor[], Tensor[]) _case_verify_and_canonicalize_args(Tensor[] pred_fn_pairs, bool exclusive, string name, bool allow_python_preds)
{
throw new NotImplementedException("_case_verify_and_canonicalize_args");
}

public static Tensor case_v2(Tensor[] pred_fn_pairs, Func<Tensor[]> callable_default = null, bool exclusive = false, bool strict = false, string name = "case")
=> _case_helper(
cond_fn: (Tensor x) => cond(x),
pred_fn_pairs,
default,
exclusive,
name,
allow_python_preds: false//,
//strict: strict
);

/// <summary> /// <summary>
/// Produces the content of `output_tensor` only after `dependencies`. /// Produces the content of `output_tensor` only after `dependencies`.
/// ///


+ 6
- 8
src/TensorFlowNET.Core/Operations/image_ops_impl.cs View File

@@ -265,15 +265,13 @@ namespace Tensorflow
return gen_array_ops.reverse(array_ops.transpose(image, new [] {1, 0, 2}), new [] {1}); return gen_array_ops.reverse(array_ops.transpose(image, new [] {1, 0, 2}), new [] {1});
}; };


var cases = new [] {new [] {math_ops.equal(k, 1), _rot90()},
new [] {math_ops.equal(k, 2), _rot180()},
new [] {math_ops.equal(k, 3), _rot270()}};
var cases = new [] {math_ops.equal(k, 1), _rot90(),
math_ops.equal(k, 2), _rot180(),
math_ops.equal(k, 3), _rot270()};
// ! control_flow_ops doesn't have an implementation for case yet !
// var result = control_flow_ops.case(cases, default: () => image, exclusive: true, name: name_scope);
// result.set_shape(new [] {null, null, image.shape.dims[2]})
// return result
throw new NotImplementedException();
var result = control_flow_ops.case_v2(cases, callable_default: () => new Tensor[] {image}, exclusive: true, name: name_scope);
result.set_shape(new [] {-1, -1, image.TensorShape.dims[2]});
return result;
} }


public static Tensor transpose(Tensor image, string name = null) public static Tensor transpose(Tensor image, string name = null)


Loading…
Cancel
Save