我想让这个 repo https://github.com/ildoonet/tf-pose-estimation与 Intel Movidius 一起运行,所以我尝试使用 mvNCCompile 转换 pb 模型。
问题是 mvNCCompile 需要固定的输入形状,但我拥有的模型是动态的。
我试过这个
graph_path = 'models/graph/mobilenet_thin/graph_opt.pb'
with tf.gfile.GFile(graph_path, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
graph = tf.get_default_graph()
tf.import_graph_def(graph_def, name='TfPoseEstimator')
x = graph.get_tensor_by_name('TfPoseEstimator/image:0')
x.set_shape([1, 368, 368, 3])
x = graph.get_tensor_by_name('TfPoseEstimator/MobilenetV1/Conv2d_0/Conv2D:0')
x.set_shape([1, 368, 368, 24])
Run Code Online (Sandbox Code Playgroud)
得到了这个
(<tf.Tensor 'TfPoseEstimator/MobilenetV1/Conv2d_0/weights:0' shape=(3, 3, 3, 24) dtype=float32>,)
(<tf.Tensor 'TfPoseEstimator/image:0' shape=(1, 368, 368, 3) dtype=float32>,)
(<tf.Tensor 'TfPoseEstimator/MobilenetV1/Conv2d_0/Conv2D:0' shape=(1, 368, 368, 24) dtype=float32>,)
(<tf.Tensor 'TfPoseEstimator/MobilenetV1/Conv2d_0/Conv2D_bn_offset:0' shape=(24,) dtype=float32>,)
(<tf.Tensor 'TfPoseEstimator/MobilenetV1/Conv2d_0/BatchNorm/FusedBatchNorm:0' shape=(?, ?, ?, 24) dtype=float32>,)
(<tf.Tensor …Run Code Online (Sandbox Code Playgroud) 我正在尝试为离散动作空间实现软演员评论家算法,但我在损失函数方面遇到了麻烦。
这是来自 SAC 的具有连续动作空间的链接:https : //spinningup.openai.com/en/latest/algorithms/sac.html
我不知道我做错了什么。
问题是网络在cartpole环境中没有学到任何东西。
github上的完整代码:https : //github.com/tk2232/sac_discrete/blob/master/sac_discrete.py
这是我的想法,如何计算离散动作的损失。
class ValueNet:
def __init__(self, sess, state_size, hidden_dim, name):
self.sess = sess
with tf.variable_scope(name):
self.states = tf.placeholder(dtype=tf.float32, shape=[None, state_size], name='value_states')
self.targets = tf.placeholder(dtype=tf.float32, shape=[None, 1], name='value_targets')
x = Dense(units=hidden_dim, activation='relu')(self.states)
x = Dense(units=hidden_dim, activation='relu')(x)
self.values = Dense(units=1, activation=None)(x)
optimizer = tf.train.AdamOptimizer(0.001)
loss = 0.5 * tf.reduce_mean((self.values - tf.stop_gradient(self.targets)) ** 2)
self.train_op = optimizer.minimize(loss, var_list=_params(name))
def get_value(self, s):
return self.sess.run(self.values, feed_dict={self.states: s})
def update(self, s, targets):
self.sess.run(self.train_op, …Run Code Online (Sandbox Code Playgroud) 我看到垃圾邮件预测将邮件分类为其他人制作的垃圾邮件和火腿.
该程序生成以下值.(损失,准确)
在此代码中,结果只是损失,准确性,
我认为准确性毫无意义.我需要精确度,召回值(F1测量)
但是,由于我的代码分析工作不正常,我知道Precision和Recall.但我不知道如何在此代码中计算(代码嵌入)Precision和Recall.
在谈到图像/计算机视觉时,我试图了解 CNN 架构和 RCNN 架构之间的基本概念差异。
如果我错了,请纠正我,但据我所知,CNN 提供空间不变性(位置),而 RNN 提供时间不变性(时间)。
artificial-intelligence deep-learning conv-neural-network tensorflow recurrent-neural-network
我正在尝试用两个类进行图像分类.我有1000张平衡类的图像.当我训练模型时,我得到的恒定验证精度低,但验证损失减少.这是过度拟合还是过度拟合的迹象?我还应该注意到,我正在尝试使用新类和不同的数据集重新训练Inception V3模型.
Epoch 1/10
2/2 [==============================]2/2 [==============================] - 126s 63s/step - loss: 0.7212 - acc: 0.5312 - val_loss: 0.7981 - val_acc: 0.3889
Epoch 2/10
2/2 [==============================]2/2 [==============================] - 70s 35s/step - loss: 0.6681 - acc: 0.5959 - val_loss: 0.7751 - val_acc: 0.3889
Epoch 3/10
2/2 [==============================]2/2 [==============================] - 71s 35s/step - loss: 0.7313 - acc: 0.4165 - val_loss: 0.7535 - val_acc: 0.3889
Epoch 4/10
2/2 [==============================]2/2 [==============================] - 67s 34s/step - loss: 0.6254 - acc: 0.6603 - val_loss: 0.7459 - …Run Code Online (Sandbox Code Playgroud) 问题:
在github中:
import (
"runtime"
"unsafe"
"github.com/golang/protobuf/proto"
tfpb "github.com/tensorflow/tensorflow/tensorflow/go/genop/internal/proto/github.com/tensorflow/tensorflow/tensorflow/go/core"
)
Run Code Online (Sandbox Code Playgroud)
这是什么(tfpb“github.com/tensorflow/tensorflow/tensorflow/go/genop/internal/proto/github.com/tensorflow/tensorflow/tensorflow/go/core”)?我在任何地方都找不到它,我的程序也找不到我该如何解决这个问题
有详细信息:今天我尝试为 Go 安装 tensorflow 并执行它,我使用这个 cmd:
go get github.com/tensorflow/tensorflow/tensorflow/go
然后我测试 tf 去:
go test github.com/tensorflow/tensorflow/tensorflow/go
(根据本网站:tensorflow)
但我收到了这条消息:
在以下任何一个中找不到包“github.com/tensorflow/tensorflow/tensorflow/go/genop/internal/proto/github.com/tensorflow/tensorflow/tensorflow/go/core”:/home/go/src/github.com /tensorflow/tensorflow/tensorflow/go/genop/internal/proto/github.com/tensorflow/tensorflow/tensorflow/go/core(来自$GOROOT)
/home/go_work/src/github.com/tensorflow/tensorflow/tensorflow/go/genop/internal/proto/github.com/tensorflow/tensorflow/tensorflow/go/core(来自$GOPATH)
然后我访问github然后我找不到这个路径,我该如何解决这个问题?谢谢你们。!
我有一个faces列表,其中列表的每个元素都是一个形状为 ( 1, 224, 224, 3) 的 numpy 数组,即人脸图像。我有一个模型,其输入形状为(None, 224, 224, 3),输出形状为(None, 2)。
现在我想对faces列表中的所有图像进行预测。当然,我可以遍历列表并一个一个地得到预测,但我想将所有图像作为一个批次处理,只使用一次调用来model.predict()更快地获得结果。
如果我像现在这样直接传递人脸列表(最后是完整的代码),我只会得到第一张图像的预测。
print(f"{len(faces)} faces found")
print(faces[0].shape)
maskPreds = model.predict(faces)
print(maskPreds)
Run Code Online (Sandbox Code Playgroud)
输出:
3 faces found
(1, 224, 224, 3)
[[0.9421933 0.05780665]]
Run Code Online (Sandbox Code Playgroud)
但是maskPreds对于 3 个图像应该是这样的:
[[0.9421933 0.05780665],
[0.01584494 0.98415506],
[0.09914105 0.9008589 ]]
Run Code Online (Sandbox Code Playgroud)
完整代码:
print(f"{len(faces)} faces found")
print(faces[0].shape)
maskPreds = model.predict(faces)
print(maskPreds)
Run Code Online (Sandbox Code Playgroud)
注意:如果我不将每个图像从 (224, 224, 3) 转换为 ( 1, 224, 224, 3),tensorflow 会抛出错误,指出输入维度不匹配。
ValueError: Error when checking …Run Code Online (Sandbox Code Playgroud) 任何人都知道如何安装 Pandas(并实际导入),而不是在 Rosetta 下才能使用 Apple 的分叉 TensorFlow 在本机 M1 模式下使用?我只能做一个或另一个,而我需要两者。如果我在 Rosetta TF 下安装将不起作用。如果我为 M1 安装 Apple 的 TF,则不会安装 Pandas。
(x_train, y_train), (x_test, y_test) = mnist.load_data()
这是 tensorflow 示例,但我不明白这意味着什么我知道 x_train、y_train、x_test、y_test 的目的,但我想知道它们是如何分配的。这是一种什么样的机制。谢谢
我正在尝试使用 CoRA 数据集在张量流上训练图神经网络,这是我第一次使用 Spektral。
经过在互联网上的一些研究,我了解到 Spektral 应该有一个有用的加载器函数供我加载这个基准数据集,所以我尝试实现它:
adj,features,labels,train_mask,val_mask,test_mask=spektral.datasets.citation.load_data(dataset_name="cora")
Run Code Online (Sandbox Code Playgroud)
然后我得到了这个:
AttributeError: module 'spektral.datasets.citation' has no attribute 'load_data'
Run Code Online (Sandbox Code Playgroud)
我检查了 Spektral 文档,但没有找到load_data加载器功能,所以我认为有更新或其他内容。
如果任何人都可以提供任何替代方案或可能的错误解释,那将会很有帮助。