采用TensorFlow支持通过tf.Graph函数来生成新的向量图,代码如下:

import tensorflow as tf g1 = tf.Graph() with g1.as_default(): v = tf.get_variable( "v",initializer=tf.zeros_initializer(shape = [1])) g2 = tf.Graph() with g2.as_default(): v = tf.get_variable( "v",initializer=tf.ones_initializer(shape = [1])) with tf.Session(graph=g1) as sess: tf.initialize_all_variables().run() with tf.variable_scope("",reuse=True): print(sess.run(tf.get_variable("v"))) with tf.Session(graph=g2) as sess: tf.initialize_all_variables().run() with tf.variable_scope("",reuse=True): print(sess.run(tf.get_variable("v")))

执行后发生如下错误:

解决办法:因为上述代码写法是TensorFlow旧版本的写法,将Line6 和Line10 改如下如下可以实现代码的正常运行:

v = tf.get_variable("v",initializer=tf.zeros_initializer()(shape = [1]))

v = tf.get_variable( "v",initializer=tf.ones_initializer()(shape = [1]))

输出结果如下图:

明显有一个更新提示,表示该初始化的语句也需要进行更新:

tf.initialize_all_variables().run() 变成 tf.global_variables_initializer().run()

最后输出结果:

源于博客:https://blog.csdn.net/li_haiyu/article/category/7625657

ypeError: __init__() got an unexpected keyword argument 'shape'的更多相关文章

  1. senlin __init__() got an unexpected keyword argument 'additional_headers'

    从senlin源码重新编译更新了服务,然后执行 senlin的 cli就遇到了错误: __init__() got an unexpected keyword argument 'additional ...

  2. TypeError: __init__() got an unexpected keyword argument 't_command'

    python  .\manage.py migrate 报错如下 λ python .\manage.py migrateTraceback (most recent call last): File ...

  3. TypeError: __init__() got an unexpected keyword argument 'serialized_options'

    问题描述: TypeError: __init__() got an unexpected keyword argument 'serialized_options' File "objec ...

  4. Django2.0——django-filter: TypeError at *** __init__() got an unexpected keyword argument 'name'

    在使用 Django2.0 版本的 Django Rest Framwork 时,Django DeBug 报错 django-filter: TypeError at *** __init__() ...

  5. 关于Jupyter Notebook无法自动补全(Autocompletion),报错TypeError: __init__() got an unexpected keyword argument 'column' 的解决方案

    关于Jupyter Notebook无法自动补全(Autocompletion),报错TypeError: __init__() got an unexpected keyword argument ...

  6. kivy __init__() got an unexpected keyword argument '__no_builder' Kivy

    from kivy.lang.builder import Builder from kivy.app import App, runTouchApp from kivy.uix.boxlayout ...

  7. _init_() got an unexpected keyword argument ‘shape’

    按照<TensorFlow:实战Google深度学习框架>一书学习的tensorflow,书中使用的是0.9.0版本,而我安装的是1.11.0 如果按照书上的例子来,因为这本书使用tens ...

  8. django出现__init__() got an unexpected keyword argument 'mimetype‘ 问题解决

    这种问题好多新手按照djangobook学习的时候应该都遇到过,是因为这是老的django的写法,新的django已经升级改变了很多东西. 处理方法如下: I think you are not us ...

  9. Django-filter报错:__init__() got an unexpected keyword argument 'name'

    原因是 自从 django-filter2.0之后 将Filter的name字段 更名为 field_name 所以需要这样写: class GoodsFilter(filters.FilterSet ...

随机推荐

  1. 【Struts 基础案例】

    LoginAction package k.action; import k.form.UserForm; import org.apache.struts.action.*; import java ...

  2. FYF的煎饼果子

    利用等差数列公式就行了,可以考虑特判一下m >= n($ m, n \neq 1 $),这时一定输出“AIYAMAYA”. #include <iostream> using nam ...

  3. HITCON-Training-master 部分 Writeup(1月30更新)

    0x01.lab3 首先checksec一下,发现连NX保护都没开,结合题目提示ret2sc,确定可以使用shellcode得到权限. IDA查看伪代码 大致分析: 将shellcode写入name数 ...

  4. 02-Docker认识与原理

    目录 02-Docker认识与原理 参考 Docker认识 Docker特性 Docker对比VM Docker社区版本 Docker原理 Docker engine Docker architect ...

  5. ASP.NET Core搭建多层网站架构【12-xUnit单元测试之集成测试】

    2020/02/01, ASP.NET Core 3.1, VS2019, xunit 2.4.1, Microsoft.AspNetCore.TestHost 3.1.1 摘要:基于ASP.NET ...

  6. Vacuum Pump Manufacturer - Vacuum Pump: Prevents Reactive Compound Decomposition Products

    Vacuum packaging has been popular in the industry for a long time. Many large companies have joined ...

  7. 吴裕雄--天生自然TensorFlow2教程:梯度下降简介

    import tensorflow as tf w = tf.constant(1.) x = tf.constant(2.) y = x * w with tf.GradientTape() as ...

  8. shell 脚本基础

    弱类型语言 bash 变量类型 本地变量 环境变量 局部变量 位置参数变量 特殊变量 运行 无执行权限 bash hello.sh 有执行权限 检查语法 bash -n user.sh 跟踪每一行的执 ...

  9. MAC系统 -java开发环境搭建

    MAC - java开发环境搭建 软件: jdk Intellij IDEA:java开发工具 maven:jar包管理 git :源码管理 sourceTree :源码管理GUI客户端 Studio ...

  10. HDU1495 非常可乐(BFS/数论)

    大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为.因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多.但see ...