Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# tf.train.Saver()不适用于Tensorflow.net_C#_Tensorflow_Machine Learning_.net Core - Fatal编程技术网

C# tf.train.Saver()不适用于Tensorflow.net

C# tf.train.Saver()不适用于Tensorflow.net,c#,tensorflow,machine-learning,.net-core,C#,Tensorflow,Machine Learning,.net Core,上面的简单代码在下一行导致异常。原因是什么? 请使用NuGet Manager获取 TensorFlow.NET SciSharp.TensorFlow.Redist 测试前的包装 using System; using Tensorflow; using static Tensorflow.Binding; namespace ConsoleApp1 { class Program { static void Main(string[] args)

上面的简单代码在下一行导致异常。原因是什么? 请使用NuGet Manager获取

  • TensorFlow.NET
  • SciSharp.TensorFlow.Redist
  • 测试前的包装

    using System;
    using Tensorflow;
    using static Tensorflow.Binding;
    
    namespace ConsoleApp1
    {
        class Program
        {
            static void Main(string[] args)
            {
                var w1 = tf.Variable(0, name: "save1");
                var init_op = tf.global_variables_initializer();
                // Add ops to save and restore all the variables.
                var saver = tf.train.Saver(new IVariableV1[]{w1 });
                using (var sess = tf.Session())
                {
                    sess.run(init_op);
                    // Save the variables to disk.
                    var save_path = saver.save(sess, "/tmp/model1.ckpt");
                    Console.WriteLine($"Model saved in path: {save_path}");
                }
                Console.ReadKey();
            }
        }
    }
    

    @磁控管虽然标签的更正是赞赏的,但一定要解决所有问题的帖子时,编辑他们。
    var saver = tf.train.Saver(new IVariableV1[]{w1 });
    System.NullReferenceException: 'Object reference not set to an instance of an object.'