- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当我运行以下代码(来自 this IPython notebook )时,出现错误:
import theano
def get_submodel(model, start, end):
return theano.function([model.layers[start].input],
model.layers[end].get_output(train=False),
allow_input_downcast=True)
def get_encoder(ae):
return get_submodel(ae, 0, (len(ae.layers) // 2) - 1)
ae_encoder = get_encoder(ae)
这是错误消息:
Traceback (most recent call last):
File "Parametric t-SNE (Keras).py", line 432, in <module>
ae_encoder = get_encoder(ae)
File "Parametric t-SNE (Keras).py", line 424, in get_encoder
return get_submodel(ae, 0, (len(ae.layers) // 2) - 1)
File "Parametric t-SNE (Keras).py", line 422, in get_submodel
allow_input_downcast=True)
File "/usr/lib64/python3.4/site-packages/theano/compile/function.py", line 326, in function
output_keys=output_keys)
File "/usr/lib64/python3.4/site-packages/theano/compile/pfunc.py", line 397, in pfunc
for p in params]
File "/usr/lib64/python3.4/site-packages/theano/compile/pfunc.py", line 397, in <listcomp>
for p in params]
File "/usr/lib64/python3.4/site-packages/theano/compile/pfunc.py", line 496, in _pfunc_param_to_in
raise TypeError('Unknown parameter type: %s' % type(param))
TypeError: Unknown parameter type: <class 'tensorflow.python.framework.ops.Tensor'>
作为引用,这里是 ae
的定义位置:
n = X_train.shape[1]
ae = Sequential()
ae.add(Dense(500, activation='relu', weights=encoder.layers[0].get_weights(), input_shape=(n,)))
ae.add(Dense(500, activation='relu', weights=encoder.layers[1].get_weights()))
ae.add(Dense(2000, activation='relu', weights=encoder.layers[2].get_weights()))
ae.add(Dense(2, weights=encoder.layers[3].get_weights()))
ae.add(Dense(2000, activation='relu', weights=decoder.layers[0].get_weights()))
ae.add(Dense(500, activation='relu', weights=decoder.layers[1].get_weights()))
ae.add(Dense(500, activation='relu', weights=decoder.layers[2].get_weights()))
ae.add(Dense(n, weights=decoder.layers[3].get_weights()))
ae.compile(loss='mse', optimizer='rmsprop')
ae.fit(X_train, X_train, nb_epoch=100, verbose=2, batch_size=32)
基于a similar question的答案,我怀疑可能需要修改 get_submodel
以使用符号变量而不是张量/矩阵。但是,我不确定如何执行此操作,以及为什么它甚至会给出错误,因为 GitHub 上的 IPython 笔记本似乎不包含任何错误消息。我无法找到有关 tensorflow.python.framework.ops.Tensor
错误消息的更具体建议。
最佳答案
看来您有一个 tensorflow
后端 - 而不是 theano
后端。这就是使用 theano.function
会生成错误的原因。尝试使用keras.backend.function
。
关于python - Theano,类型错误: Unknown parameter type: <class 'tensorflow.python.framework.ops.Tensor' >,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47124427/
我正在KERAS CNN中工作,以检测视网膜图像中的糖尿病性视网膜病变。但是,当我尝试使用此代码预处理图像..: def estimate_radius(img): mx = img[img.
为什么这样实现: T& T::operator+=(const T&) { // ... implementation ... return *this; } T operator+(cons
这是我的图像混合代码,但 cv2.addweighted() 函数有问题: import cv2 import numpy as np img1 = cv2.imread('1.png') img2
我正在设置一个搜索API,就是搜索; id、type、originCity、destinationCity、departmentDate、reason、accommodation、approvalSt
这两个特征(std::ops::Add,core::ops::Add)提供相同的功能,并且它们都使用相同的示例(都使用std::ops::Add)。他们的实现者集有所不同。 应该默认使用std::op
我要提出条件 (A 和 B)和(C 或 D 或 E 或 F) 当我尝试做的时候 where: { [Op.and]: [{ A, B, [Op.or]: [{
我对 Sequelize 有这个问题: 我正在尝试进行 3 参数研究,如果其中一个参数为空,则不应考虑该参数。 const users = await User.findAll({ where:
Herb Sutter 的 Guru of the Week #4, "Class Mechanics" ,教导重载运算符的“a op b”形式应该根据“a op= b”形式实现(参见解决方案中的第
基准代码: func BenchmarkSth(b *testing.B) { var x []int b.ResetTimer() for i := 0; i < b.N;
我在使用 sequelize 获取正确的查询时遇到问题。 我有一个表示条目 id 的数组,可以这样说 - userVacationsIds = [1,2,3] 我做了这样的第一个查询
这两个特征(std::ops::Add,core::ops::Add)提供相同的功能,并且它们都使用相同的示例(都利用 std::ops::Add)。他们的一组实现者有些不同。 是否应该默认使用 st
为什么 std::numeric 算法似乎更喜欢 op 而不是 op=?例如,这里是 std::accumulate 在 LLVM 中的实现: template inline _LIBCPP_INL
这是基准测试的代码片段: // bench_test.go package main import ( "testing" ) func BenchmarkHello(b *testing.B
我使用 Sequelize 来查询我的数据库。 我在查询中使用 Op.and 和 Op.ne: const Op = require('sequelize'); let subLevels = awa
我有一个关于链表和模板的作业,其中有带有奇怪参数的函数,这些参数是强制性的。我找不到关于它的在线文档,感谢任何提供的 Material 。 我曾尝试为 op 分配另一个地址,然后它编译得很好,但我无法
cppreference说: the behavior of every builtin compound-assignment expression E1 op= E2 (where E1 is a
当我使用 go test -v -bench=. -benchmem 运行基准测试时,我看到以下结果。 f1 10000 120860 ns/op 2433 B/o
假设我有一个sympy 表达式 e1 op e2 哪里op是任何算术比较运算符,例如 , >> from sympy import symbols, Piecewise, ccode >>> x, y
在我的玩具包中,我定义了 %+%运算符作为 paste0() 的别名.试图减少与其他包的干扰,我通过以下方式实现: `%+%` <- function(...) UseMethod("%+%") `%
我正在尝试遵循 Scott Meyers 在 More Effective C++ 的第 22 项中的建议:“考虑使用 op= 而不是独立的 op”。他建议我们可以为 operator+ 创建一个模板
我是一名优秀的程序员,十分优秀!