在张量流中加载多个DNN模型并多次使用

时间:2018-06-27 05:15:54

标签: python tensorflow machine-learning deep-learning

我有两种Inception-v3模型(.data,.index,.meta文件)的检查点

我想在程序开始时将它们都加载到内存中,并在while循环中同时使用它们。

load model1
load model2
while True :
    predict output from model1
    predict output from model2

我得到的错误是因为我在两个变量上使用了相同的图形。我添加了一个解决问题的答案

1 个答案:

答案 0 :(得分:0)

这是我用来解决此问题的以下代码。

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_message_dialog);
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
}

@Override
protected void onResume() {
    super.onResume();

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();

    if(extras == null)
        return;

    String strTopic = extras.getString(Constants.INTENT_TOPIC);
    String strMessage = extras.getString(Constants.INTENT_MESSAGE);
}

<activity
    android:name=".PushMeMessageDialogActivity"
    android:launchMode="singleTop"
    android:theme="@android:style/Theme.Dialog"
    android:excludeFromRecents="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

minSdkVersion 22
targetSdkVersion 28