c# - How to reshape a tensor in TensorFlowSharp -
tensorflowsharp wrapper of tensorflow in c# platform. click jump tensorflowshape github
now need reshape tensor shape [32,64,1] new tensor shape [1, 2048].but refer official api document, usage seems that:
tfoutput reshape (tensorflow.tfoutput tensor, tensorflow.tfoutput shape);
the problem dont know how express shape need in way of tfoutput
suggestions appreciated:)!
in standard tensorflowsharp, example on how operation can given by:
tf.reshape(x, tf.const(shape));
where tf
current default tfgraph in tfsession.
alternatively, if use keras sharp, might able operation using
using (var k = new tensorflowbackend()) { double[,] input_array = new double[,] { { 1, 2 }, { 3, 4 } }; tensor variable = k.variable(array: input_array); tensor variable_new_shape = k.reshape(variable, new int[] { 1, 4 }); double[,] output = (double[,])variable_new_shape.eval(); assert.areequal(new double[,] { { 1, 2, 3, 4 } }, output); }
as indicated in https://github.com/cesarsouza/keras-sharp/blob/efac7e34457ffb7cf6712793d5298b565549a1c2/tests/tensorflowbackendtest.cs#l45
Comments
Post a Comment