采用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. springMVC的概念

    1,完成一次web请求的过程 Web浏览器发起请求 Web服务器接收请求并处理请求,最后产生响应(一般为html).web服务器处理完成后,返回内容给web客户端,客户端对接收的内容进行处理并显示出来 ...

  2. vue 路由传参 以及获取参数

    1.通过query实现: <router-link :to="{ name:'home',query:{id:1} }">跳转页面</router-link> ...

  3. 吴裕雄 python 机器学习——模型选择学习曲线learning_curve模型

    import numpy as np import matplotlib.pyplot as plt from sklearn.svm import LinearSVC from sklearn.da ...

  4. 对图书管理系统5W1H的分析

    5W1H 对图书管理系统的分析 1.Who 学生.老师和图书馆管理员 2.When 借还书的时候使用,还有用户流量的统计在每天晚上都会看一下有多少人哪些人看了的,基本绝大多数时间都可以看 3.Wher ...

  5. Python 命令行参数的输入方式(使用pycharm)

    形式一: 第一个红色框为命令行参数 第二个框为控制台模式(Terminal) 形式二 点击运行:点击红色框  编辑配置 如下图:红色框即为设置的命令行参数

  6. 主机与虚拟机连接,主机能ping通虚拟机虚拟机ping不通主机问题

    事件描述: 从物理主机ping虚拟机时,能正常返回信息.反之,从虚机ping物理主机时返回信息:Destination Host unreachable.   解决方法: 首先,是因为默认创建的虚拟机 ...

  7. Ubuntu国内镜像

    编辑文件:sudo vim /etc/apt/sources.list 全部替换为:如下根据需要替换一个即可,修改保存后记得要执行更新软件包列表命令: sudo apt-get update 一.清华 ...

  8. 关闭AnyConnect登录安全警告窗口

    一.问题描述:使用AnyConnect client连接时,如何关闭的安全警告窗口? 二.原因分析:   AnyConnect Server(ASA)和AnyConect client(PC)上没有受 ...

  9. Solidity基本数据结构

    任何一个智能合约都会在最开头表示使用的编译器版本 如:prama solidity ^0.4.0 数组: //静态数组 大小长度确定 uint[2] fixedArray; //动态数组,可以随意添加 ...

  10. spring aop @after和@before之类的注解,怎么指定多个切点

    有如下两个切点: @Pointcut("execution(public * com.wyh.data.controller.DepartmentController.*(..))" ...