On Tensorflow 2.0, whenever I pass a Pandas DataFrame as the input, then Tensorflow works fine but prints out a warning WARNING:tensorflow:Falling back from v2 loop because of error: Failed to find data adapter that can handle input: <class 'pandas.core.frame.DataFrame'>, <class 'NoneType'>. I don't recall ever getting that error with TF 1.x so this must be new. But why is it a warning?
I understand what it's asking for, and yes, converting that DataFrame to a pure numpy array …
我在尝试在android中应用tensorflow model(.pb)时遇到错误,该模型已成功加载,但是在收到此错误之后,我在CPU上训练了tensorflow模型。任何帮助将不胜感激。
没有注册任何OpKernel支持这些属性的Op'Round'。注册设备:[CPU],注册内核:
谢谢。
好的,所以在我的应用程序中,我尝试使用人脸网络模型实现人脸识别,该模型转换为 tflite 平均约为 93 MB,但是该模型最终会增加我的 apk 的大小。所以我正在努力寻找替代方法来处理这个问题
首先我能想到的是以某种方式压缩它,然后在安装应用程序时解压缩
另一种方法是我应该将该模型上传到服务器,并在下载后将其加载到我的应用程序中。但是我似乎不知道如何实现这一点:
默认情况下,face net 允许从 assets 文件夹中实现
var facenet = FaceNet(getAssets());
Run Code Online (Sandbox Code Playgroud)
但是,如果我正在下载该模型,如何将其加载到我的应用程序中?
这是我的脸网初始化代码:
public FaceNet(AssetManager assetManager) throws IOException {
tfliteModel = loadModelFile(assetManager);
tflite = new Interpreter(tfliteModel, tfliteOptions);
imgData = ByteBuffer.allocateDirect(
BATCH_SIZE
* IMAGE_HEIGHT
* IMAGE_WIDTH
* NUM_CHANNELS
* NUM_BYTES_PER_CHANNEL);
imgData.order(ByteOrder.nativeOrder());
}
private MappedByteBuffer loadModelFile(AssetManager assetManager) throws IOException {
AssetFileDescriptor fileDescriptor = assetManager.openFd(MODEL_PATH);
FileInputStream inputStream = new FileInputStream(fileDescriptor.getFileDescriptor());
FileChannel fileChannel = inputStream.getChannel();
long startOffset = fileDescriptor.getStartOffset();
long declaredLength = fileDescriptor.getDeclaredLength();
return fileChannel.map(FileChannel.MapMode.READ_ONLY, startOffset, declaredLength); …Run Code Online (Sandbox Code Playgroud) 我试图在 PyCharm 中运行以下代码行,并且安装并导入了 tensorflow_hub。
use = hub.load("https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/3")
Run Code Online (Sandbox Code Playgroud)
对于以下错误有什么建议吗?因为我的项目需要这个。
Traceback (most recent call last):
File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3820, in _get_op_def
return self._op_def_cache[type]
KeyError: 'SentencepieceOp'
Run Code Online (Sandbox Code Playgroud)
在处理上述异常的过程中,又发生了一个异常:
Traceback (most recent call last):
File "C:/Users/Jon10/OneDrive/Documents/Computer Science/Dissertation/PythonPractice/TFTest/test.py", line 28, in <module>
use = hub.load("https://tfhub.dev/google/universal-sentence-encoder-multilingual-large/3")
File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_hub\module_v2.py", line 102, in load
obj = tf_v1.saved_model.load_v2(module_path, tags=tags)
File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\saved_model\load.py", line 517, in load
return load_internal(export_dir, tags)
File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\saved_model\load.py", line 541, in load_internal
export_dir)
File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\saved_model\load.py", line 114, in __init__
meta_graph.graph_def.library))
File "C:\Users\Jon10\miniconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\saved_model\function_deserialization.py", line 312, in load_function_def_library
copy, copy_functions=False) …Run Code Online (Sandbox Code Playgroud) 据我了解,TensorFlow 使用MLMD来记录和检索与工作流相关的元数据。这可能包括:
特征:
以上(例如#1 又名“组件结果”)是否暗示 MLMD 存储实际数据?(例如机器学习训练的输入特征?)。如果不是,管道组件的结果是什么意思?
编排和管道历史:
此外,当使用 TFX 与例如 AirFlow 时,它使用自己的元存储(例如关于 DAG、它们的运行和其他 Airflow 配置(如用户、角色和连接)的元数据)MLMD 是否存储冗余信息?它会取代它吗?
我tf.keras.Model在将自定义循环中经过训练的子类模型 ( )转换为 TFLite 时遇到问题。
假设我们有一个小的 CNN 架构,它使用输入数据 ( x) 和取决于批量大小和其他维度 ( add_info) 的附加信息:
class ContextExtractor(tf.keras.Model):
def __init__(self):
super().__init__()
self.model = self.__get_model()
def call(self, x, training=False, **kwargs):
b, h, w, c = x.shape
add_info = tf.zeros((b, h, w, c), dtype=tf.float32)
features = self.model(tf.concat([x, add_info], axis=-1), training=training)
return features
def __get_model(self):
return self.__get_small_cnn()
def __get_small_cnn(self):
model = tf.keras.Sequential()
model.add(layers.Conv2D(32, (3, 3), strides=(2, 2), padding='same'))
model.add(layers.LeakyReLU(alpha=0.2))
model.add(layers.Conv2D(32, (3, 3), strides=(2, 2), padding='same'))
model.add(layers.LeakyReLU(alpha=0.2))
model.add(layers.Conv2D(64, (3, 3), strides=(2, 2), …Run Code Online (Sandbox Code Playgroud) 我正在查看Tensorflow tf.nn.quantized_conv2d函数,并且想知道qint8等确切是什么数据类型,特别是如果它们是tf.contrib.quantize中用于“伪量化节点”的数据类型,或者实际上使用8位(用于qint8)存储在内存中。
我知道它们是在tf.dtypes.DType中定义的,但是没有关于它们实际是什么的任何信息。
python quantization neural-network tensorflow tensorflow-lite
我正在使用 ML 套件集成对象检测我正在使用 firebase ML 创建自定义 tflite 模型并按照此文档https://firebase.google.com/docs/ml-kit/android/use-custom-models加载自定义模型但得到加载模型时出现以下错误
com.google.firebase.ml.common.FirebaseMLException:本地模型加载失败,模型选项为:本地模型名称:模型名称。远程型号名称:未指定。
private fun configureLocalModelSource() {
// [START mlkit_local_model_source]
val localSource = FirebaseLocalModel.Builder("my_local_model") // Assign a name to this model
.setAssetFilePath("my_model.tflite")
.build()
FirebaseModelManager.getInstance().registerLocalModel(localSource)
// [END mlkit_local_model_source]
}
@Throws(FirebaseMLException::class)
private fun createInterpreter(): FirebaseModelInterpreter? {
// [START mlkit_create_interpreter]
val options = FirebaseModelOptions.Builder()
.setRemoteModelName("my_cloud_model")
.setLocalModelName("my_local_model")
.build()
val interpreter = FirebaseModelInterpreter.getInstance(options)
// [END mlkit_create_interpreter]
return interpreter
}
Run Code Online (Sandbox Code Playgroud)