ypeError: __init__() got an unexpected keyword argument 'shape'
采用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'的更多相关文章
- senlin __init__() got an unexpected keyword argument 'additional_headers'
从senlin源码重新编译更新了服务,然后执行 senlin的 cli就遇到了错误: __init__() got an unexpected keyword argument 'additional ...
- TypeError: __init__() got an unexpected keyword argument 't_command'
python .\manage.py migrate 报错如下 λ python .\manage.py migrateTraceback (most recent call last): File ...
- TypeError: __init__() got an unexpected keyword argument 'serialized_options'
问题描述: TypeError: __init__() got an unexpected keyword argument 'serialized_options' File "objec ...
- 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__() ...
- 关于Jupyter Notebook无法自动补全(Autocompletion),报错TypeError: __init__() got an unexpected keyword argument 'column' 的解决方案
关于Jupyter Notebook无法自动补全(Autocompletion),报错TypeError: __init__() got an unexpected keyword argument ...
- 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 ...
- _init_() got an unexpected keyword argument ‘shape’
按照<TensorFlow:实战Google深度学习框架>一书学习的tensorflow,书中使用的是0.9.0版本,而我安装的是1.11.0 如果按照书上的例子来,因为这本书使用tens ...
- django出现__init__() got an unexpected keyword argument 'mimetype‘ 问题解决
这种问题好多新手按照djangobook学习的时候应该都遇到过,是因为这是老的django的写法,新的django已经升级改变了很多东西. 处理方法如下: I think you are not us ...
- Django-filter报错:__init__() got an unexpected keyword argument 'name'
原因是 自从 django-filter2.0之后 将Filter的name字段 更名为 field_name 所以需要这样写: class GoodsFilter(filters.FilterSet ...
随机推荐
- 吴裕雄 python 机器学习——数据预处理嵌入式特征选择
import numpy as np import matplotlib.pyplot as plt from sklearn.svm import LinearSVC from sklearn.li ...
- JAVA-替换html中图片的路径-从html代码中提取图片路径并下载(完整版)
transHtml方法实现提取网络图片中得图片路径,将其重新下载到本地,并替换html中原来得路径 package com.googosoft.until; import java.io.Buffer ...
- Android学习09
SharedPreferences SharedPreferences,是一种轻量级的数据存储方式,采用Key/value的方式 进行映射,Sp通常用于记录一些参数配置.行为标记等! 1.获得mSha ...
- 【Struts 编码】
EncodingFilter package k.filter; import javax.servlet.*; import javax.servlet.http.HttpServlet; impo ...
- ASP.NET Core搭建多层网站架构【8.1-使用ViewModel注解验证】
2020/01/29, ASP.NET Core 3.1, VS2019 摘要:基于ASP.NET Core 3.1 WebApi搭建后端多层网站架构[8.1-使用ViewModel注解验证] 使用V ...
- 排序算法之冒泡排序的python实现
冒泡排序算法的工作原理如下: 1. 比较相邻的元素.如果第一个比第二个大(升序),就交换他们两个. 2. 对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对.这步做完后,最后的元素会是最大 ...
- JDBC通过资源文件初始化
- python 解释器声明 unix #!/usr/bin/env python
python 解释器声明 unix #!/usr/bin/env python 1. 问题的开始在代码移植到unix平台后,部分应用在运行时报如下错误:subprocess.Popen():OSErr ...
- Servlet里面request处理外部POST请求的输入流的工具类
package etcom.servlet; import java.io.BufferedReader; import java.io.IOException; import java.io.Inp ...
- bootstrap-suggest-plugin input可选可输(表单) 好用的前端插件
bootstrap-suggest-plugin DEMO下载 1.准备:页面引入(点击下载) <link rel="stylesheet" href=&q ...