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 ...
随机推荐
- CUP监测1分钟(60s)的python的matplotlib动态作图
import matplotlib.pyplot as plt import psutil import time # 第1步,导出通用字体设置 from matplotlib import font ...
- "exit"未定义标签 问题
找了两个多小时,最后才发现是版本问题.因为是网上下的代码,可能用的版本比较高,而我自己的是2.4.10版本的opencv,所以正确的代码应该是如下: CV_Error(CV_StsBadArg,&qu ...
- debug assertion failed问题解决
运行过程中出现上述问题,后来发现是vector越界问题....解决办法:不要越界就好了...
- leetcode 387
Given a string, find the first non-repeating character in it and return it's index. If it doesn't ex ...
- Git基础及进阶-系统总结
Git基础及进阶-系统总结 by 小强 2019-07-01 考虑到入职后不仅需要熟练掌握git的基本使用,在企业实际操作中还涉及一些进阶指令.作为一个程序员,熟练使用工具是一项基本技能,也是程序员的 ...
- SQLite3创建表及操作
SQLite 创建表 SQLite 的 CREATE TABLE 语句用于在任何给定的数据库创建一个新表.创建基本表,涉及到命名表.定义列及每一列的数据类型. 语法 CREATE TABLE 语句的基 ...
- Java入门笔记 09-集合
一.Collection接口方法:Collection 接口是 List.Set 和 Queue 接口的父接口,该接口里定义的方法既可用于操作 Set 集合,也可用于操作 List 和 Queue 集 ...
- python两个_多个字典合并相加
这只是符合比较正常的需求和场景. #一.适用合并两个字典(key不能相同否则会被覆盖),简单,好用. A = {'a': 11, 'b': 22} B = {'c': 48, 'd': 13} #up ...
- Codeforces Global Round 5E(构造,思维)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int main(){ ios::sync_w ...
- Python图文识别技术【入门必学】
Python图文识别技术分享 使用 tesseract-ORC 识别文字,识别率不算太高,需要自我训练 tessdata 数据,才能更精确的识别你想要让电脑认识出来的文字!ps:另外很多人在学习Pyt ...