我刚刚使用pip安装了Tensorflow 1.0.0.运行时,我收到如下所示的警告.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
我为SSE4.1,SSE4.2,AVX,AVX2,FMA提出了5个类似的警告.
尽管有这些警告,该计划似乎运行正常.
我想使用其中一个预先构建的keras模型(vgg,inception,resnet等)tf.keras.application进行特征提取,以节省一些时间训练.
在估算器模型函数中执行此操作的正确方法是什么?
这就是我现在拥有的.
import tensorflow as tf
def model_fn(features, labels, mode):
# Import the pretrained model
base_model = tf.keras.applications.InceptionV3(
weights='imagenet',
include_top=False,
input_shape=(200,200,3)
)
# get the output features from InceptionV3
resnet_features = base_model.predict(features['x'])
# flatten and feed into dense layers
pool2_flat = tf.layers.flatten(resnet_features)
dense1 = tf.layers.dense(inputs=pool2_flat, units=5120, activation=tf.nn.relu)
# ... Add in N number of dense layers depending on my application
logits = tf.layers.dense(inputs=denseN, units=5)
# Calculate Loss
onehot_labels = tf.one_hot(indices=tf.cast(labels, tf.int32), depth=5)
loss = tf.losses.softmax_cross_entropy(
onehot_labels=onehot_labels, logits=logits) …Run Code Online (Sandbox Code Playgroud)