我正在使用Firefox 56.在自动更新Firefox到版本56后,Firebug已经停止工作是否有任何补丁在Firefox 56版本上使用Firebug?
我正在尝试使用预先训练的模型,添加一些新的图层和操作并执行训练课程tensorflow.因此,我对tf.keras.applications.*命名空间进行了详细说明,并开始在那里使用一些已实现的模型.
加载基本模型后,我将添加这些新图层,如下所示:
x = base_model.output
# this line seems to cause my error
x = tf.reshape(x, [-1, 1])
# using this line solves the issue
# tf.keras.layers.Flatten()(x) #
x = tf.keras.layers.Dense(1024, activation="relu")(x)
x = tf.keras.layers.Dense(5, activation="softmax")(x)
Run Code Online (Sandbox Code Playgroud)
当我现在tf.keras.models.Model(...)从Tensor 创建一个新的时x,我收到此错误消息:
Output tensors to a Model must be the output of a TensorFlow `Layer`
(thus holding past layer metadata).
Found: Tensor("dense_27/Softmax:0", shape=(?, 3), dtype=float32)
Run Code Online (Sandbox Code Playgroud)
我猜这个异常是因为tf.*在tf.keras模型中使用了一个操作引起的.在这种情况下,我可以轻松地使用keras alterantive,但现在我开始想知道是否存在一种解决方法,无论如何在keras模型中使用张量操作.还是我完全限制使用tf.keras.layer.*操作?
from random import randint
from random import seed
import math
import numpy as np
from keras.models import Sequential
from keras.layers import LSTM
from keras.layers import Dense,TimeDistributed,RepeatVector
seed(1)
def ele():
X,y = [],[]
for i in range(1):
l1=[]
for _ in range(2):
l1.append(randint(1,10))
X.append(l1)
y.append(sum(l1))
for i in range(1):
X = str(X[0][0])+'+'+str(X[0][1])
y = str(y[0])
char_to_int = dict((c, i) for i, c in enumerate(alphabet))
Xenc,yenc = [],[]
for pattern in X:
integer_encoded = [char_to_int[char] for char in pattern]
Xenc.append(integer_encoded[0])
for pattern …Run Code Online (Sandbox Code Playgroud) 我试图读取用户输入的信息并将其解析为Person使用该类型的类型Gender.为此,我使用此代码:
data Person = Person String Int Gender String
data Gender = Male | Female | NotSpecified deriving Read
instance Show Gender where
show Male = "male"
show Female = "female"
show NotSpecified = "not specified"
instance Show Person where
show (Person n a g j) = "Person {name: " ++ n ++ ", age: " ++ show a ++
", gender: " ++ show g ++ ", job: " ++ j ++ "}"
readPersonMaybeT :: …Run Code Online (Sandbox Code Playgroud) 我目前正在阅读萨顿的Reinforcement Learning: An introduction书。阅读第6.1章后,我想TD(0)为此设置实现RL算法:
这样做时,我想知道如何执行此步骤A <- action given by ? for S:我可以A为当前状态选择最佳动作S吗?由于值函数V(S)仅取决于状态,而不取决于我并不真正知道的操作,因此如何实现。
我发现了这个问题(我从哪里获得图像),该问题涉及相同的练习-但在这里,操作是随机选择的,而不是由操作策略选择的?。
编辑:或者这是伪代码不完整的,所以我也必须以action-value function Q(s, a)另一种方式近似?