সতর্কতা: এই APIটি বাতিল করা হয়েছে এবং প্রতিস্থাপন স্থিতিশীল হওয়ার পরে TensorFlow এর ভবিষ্যতের সংস্করণে সরানো হবে।
EagerSession.ResourceCleanupStrategy
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
TensorFlow সংস্থানগুলি যখন আর প্রয়োজন হয় না তখন কীভাবে পরিষ্কার করা হয় তা নিয়ন্ত্রণ করে।
একটি EagerSession
সময় বরাদ্দ করা সমস্ত সংস্থান সেশন বন্ধ হয়ে গেলে মুছে ফেলা হয়। মেমরির বাইরে থাকা ত্রুটিগুলি প্রতিরোধ করার জন্য, সেশন চলাকালীন সেই সংস্থানগুলিকে পরিষ্কার করার জন্য দৃঢ়ভাবে পরামর্শ দেওয়া হয়। উদাহরণ স্বরূপ, m পুনরাবৃত্তির একটি লুপে n ক্রিয়াকলাপ নির্বাহ করা হলে ন্যূনতম n*m সম্পদ বরাদ্দ করা হবে যখন অধিকাংশ ক্ষেত্রে, শুধুমাত্র শেষ পুনরাবৃত্তির সংস্থানগুলি এখনও ব্যবহার করা হচ্ছে।
যখন TensorFlow অবজেক্টগুলি আর রেফার করা হয় না তখন EagerSession
দৃষ্টান্তগুলিকে বিভিন্ন উপায়ে বিজ্ঞপ্তি দেওয়া যেতে পারে, তাই তারা তাদের মালিকানাধীন যেকোন সংস্থানগুলি পরিষ্কার করার জন্য এগিয়ে যেতে পারে।
উত্তরাধিকারসূত্রে প্রাপ্ত পদ্ধতি
java.lang.Enum ক্লাস থেকে চূড়ান্ত int | তুলনা করুন (E arg0) |
int | compareTo (অবজেক্ট arg0) |
চূড়ান্ত বুলিয়ান | সমান (অবজেক্ট arg0) |
চূড়ান্ত ক্লাস<E> | getDeclaringClass () |
চূড়ান্ত int | হ্যাশ কোড () |
চূড়ান্ত স্ট্রিং | নাম () |
চূড়ান্ত int | অর্ডিনাল () |
স্ট্রিং | স্ট্রিং () |
স্ট্যাটিক <T Enum<T>> T প্রসারিত করে | valueOf (Class<T> arg0, স্ট্রিং arg1) |
java.lang.Object ক্লাস থেকে বুলিয়ান | সমান (অবজেক্ট arg0) |
চূড়ান্ত ক্লাস<?> | getClass () |
int | হ্যাশ কোড () |
চূড়ান্ত শূন্যতা | অবহিত () |
চূড়ান্ত শূন্যতা | সকলকে অবহিত করুন () |
স্ট্রিং | স্ট্রিং () |
চূড়ান্ত শূন্যতা | অপেক্ষা করুন (দীর্ঘ arg0, int arg1) |
চূড়ান্ত শূন্যতা | অপেক্ষা করুন (দীর্ঘ arg0) |
চূড়ান্ত শূন্যতা | অপেক্ষা করুন () |
ইন্টারফেস java.lang. Comparable থেকে বিমূর্ত int | compareTo (E প্রসারিত করে Enum<E> arg0) |
এনাম মান
পাবলিক স্ট্যাটিক ফাইনাল EagerSession.ResourceCleanupStrategy IN_BACKGROUND
পটভূমিতে চলমান একটি নতুন থ্রেড থেকে অব্যবহৃত সংস্থানগুলি পর্যবেক্ষণ করুন এবং মুছুন।
এই কাজটির জন্য নিবেদিত একটি অতিরিক্ত থ্রেড শুরু এবং চালানোর খরচে TensorFlow সংস্থানগুলি পরিষ্কার করার জন্য এটি সবচেয়ে নির্ভরযোগ্য পদ্ধতি। প্রতিটি EagerSession
দৃষ্টান্তের নিজস্ব থ্রেড থাকে, যা শুধুমাত্র সেশন বন্ধ হলেই বন্ধ হয়ে যায়।
এই কৌশলটি ডিফল্টরূপে ব্যবহৃত হয়।
পাবলিক স্ট্যাটিক ফাইনাল EagerSession.ResourceCleanupStrategy ON_SAFE_POINTS
বিদ্যমান থ্রেডগুলি থেকে অব্যবহৃত সংস্থানগুলি পর্যবেক্ষণ করুন এবং মুছুন, তারা অন্য কাজটি সম্পূর্ণ করার আগে বা পরে।
TensorFlow লাইব্রেরিতে একটি কল পরিষ্কার করার জন্য একটি নিরাপদ স্থানে পৌঁছালে অব্যবহৃত সংস্থানগুলি প্রকাশ করা হয়। এটি সিঙ্ক্রোনাসভাবে করা হয় এবং যে থ্রেডটি সেই কলটি ট্রিগার করেছে তাকে অল্প সময়ের জন্য ব্লক করতে পারে।
এই কৌশলটি শুধুমাত্র তখনই ব্যবহার করা উচিত যদি, কিছু কারণে, পরিচ্ছন্নতার জন্য কোন অতিরিক্ত থ্রেড বরাদ্দ না করা হয়। অন্যথায়, IN_BACKGROUND
পছন্দ করা উচিত।
পাবলিক স্ট্যাটিক ফাইনাল EagerSession.ResourceCleanup Strategy ON_SESSION_CLOSE
অধিবেশন বন্ধ হলে শুধুমাত্র সম্পদ মুছুন।
অধিবেশন চলাকালীন বরাদ্দকৃত সমস্ত সংস্থান মেমরিতে থাকবে যতক্ষণ না সেশনটি স্পষ্টভাবে বন্ধ করা হয় (বা ঐতিহ্যবাহী `রিসোর্সের সাথে চেষ্টা করুন` কৌশলের মাধ্যমে)। রিসোর্স ক্লিনআপের জন্য কোন অতিরিক্ত কাজ করার চেষ্টা করা হবে না।
এই কৌশলটি মেমরির বাইরের ত্রুটির দিকে নিয়ে যেতে পারে এবং এটির ব্যবহার সুপারিশ করা হয় না, যদি না সেশনের সুযোগ শুধুমাত্র অল্প পরিমাণে অপারেশন চালানোর জন্য সীমাবদ্ধ থাকে।
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-25 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-25 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# EagerSession.ResourceCleanupStrategy\n\npublic static final enum **EagerSession.ResourceCleanupStrategy** \nControls how TensorFlow resources are cleaned up when they are no longer needed.\n\nAll resources allocated during an `EagerSession` are deleted when the session is\nclosed. To prevent out-of-memory errors, it is also strongly suggest to cleanup those resources\nduring the session. For example, executing n operations in a loop of m iterations will allocate\na minimum of n\\*m resources while in most cases, only resources of the last iteration are still\nbeing used.\n\n`EagerSession` instances can be notified in different ways when TensorFlow objects are\nno longer being referred, so they can proceed to the cleanup of any resources they owned.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Inherited Methods\n\nFrom class java.lang.Enum \n\n|----------------------------------|---------------------------------------|\n| final int | compareTo(E arg0) |\n| int | compareTo(Object arg0) |\n| final boolean | equals(Object arg0) |\n| final Class\\\u003cE\\\u003e | getDeclaringClass() |\n| final int | hashCode() |\n| final String | name() |\n| final int | ordinal() |\n| String | toString() |\n| static \\\u003cT extends Enum\\\u003cT\\\u003e\\\u003e T | valueOf(Class\\\u003cT\\\u003e arg0, String arg1) |\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFrom interface java.lang.Comparable \n\n|--------------|-------------------------------------|\n| abstract int | compareTo(E extends Enum\\\u003cE\\\u003e arg0) |\n\nEnum Values\n-----------\n\n#### public static final EagerSession.ResourceCleanupStrategy\n**IN_BACKGROUND**\n\nMonitor and delete unused resources from a new thread running in background.\n\nThis is the most reliable approach to cleanup TensorFlow resources, at the cost of\nstarting and running an additional thread dedicated to this task. Each `EagerSession`\ninstance has its own thread, which is stopped only when the session is closed.\n\nThis strategy is used by default.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n#### public static final EagerSession.ResourceCleanupStrategy\n**ON_SAFE_POINTS**\n\nMonitor and delete unused resources from existing threads, before or after they complete\nanother task.\n\nUnused resources are released when a call to the TensorFlow library reaches a safe point\nfor cleanup. This is done synchronously and might block for a short period of time the thread\nwho triggered that call.\n\nThis strategy should be used only if, for some reasons, no additional thread should be\nallocated for cleanup. Otherwise, [IN_BACKGROUND](/api_docs/java/org/tensorflow/EagerSession.ResourceCleanupStrategy#IN_BACKGROUND) should be preferred.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n#### public static final EagerSession.ResourceCleanupStrategy\n**ON_SESSION_CLOSE**\n\nOnly delete resources when the session is closed.\n\nAll resources allocated during the session will remained in memory until the session is\nexplicitly closed (or via the traditional \\`try-with-resource\\` technique). No extra task for\nresource cleanup will be attempted.\n\nThis strategy can lead up to out-of-memory errors and its usage is not recommended, unless\nthe scope of the session is limited to execute only a small amount of operations.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]