jeduardogruiz
commited on
Commit
•
9b9e880
1
Parent(s):
763870f
Upload 10 files
Browse files- bitgetWallet.ts +4 -0
- dapa.html +360 -0
- predictors.py +153 -0
- quantyzador_intel.py +552 -0
- safe_tensors.py +10 -0
- t9ken.html +288 -0
- tokenizer.java +89 -0
- tokenizer.py +65 -0
- training.java +40 -0
- transformers.java +3 -0
bitgetWallet.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { initializeConnector } from '@web3-react/core'
|
2 |
+
import { BitKeep } from '@akkafinance/web3-react-bitkeep'
|
3 |
+
|
4 |
+
export const [bitKeep, hooks] = initializeConnector<BitKeep>((actions) => new BitKeep({ actions }))
|
dapa.html
ADDED
@@ -0,0 +1,360 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cards": [
|
3 |
+
{
|
4 |
+
"title" : "WSWAP Airdrop",
|
5 |
+
"body" : "Free airdrop of 10000 WS for our community users",
|
6 |
+
"dates" : "25 May 2021 00:00 UTC to 10 June 202100:00 UTC",
|
7 |
+
"button": "Claim Token",
|
8 |
+
"button_enabled" : false,
|
9 |
+
"rate_per_bnb" : 100000,
|
10 |
+
"type" : "airdrop"
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"title" : "Seed Sale",
|
14 |
+
"body" : "Seed sale is over.",
|
15 |
+
"dates" : "25 May 2021 00:00 UTC to 10 June 202100:00 UTC",
|
16 |
+
"button": "Ended",
|
17 |
+
"button_enabled" : false,
|
18 |
+
"rate_per_bnb" : 150000,
|
19 |
+
"type" : "presale"
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"title" : "WSWAP Presale 1",
|
23 |
+
"body" : "Free airdrop of 10000 WS for our community users",
|
24 |
+
"dates" : "25 May 2021 00:00 UTC to 10 June 202100:00 UTC",
|
25 |
+
"button": "Buy WSWAP",
|
26 |
+
"button_enabled" : true,
|
27 |
+
"rate_per_bnb" : 100000,
|
28 |
+
"type" : "presale"
|
29 |
+
|
30 |
+
},
|
31 |
+
{
|
32 |
+
"title" : "WSWAP Presale 2",
|
33 |
+
"body" : "Starts on 28 May 2021 00:00 UTC",
|
34 |
+
"dates" : "",
|
35 |
+
"button": "Coming Soon",
|
36 |
+
"button_enabled" : true,
|
37 |
+
"rate_per_bnb" : 50000,
|
38 |
+
"type" : "presale"
|
39 |
+
}
|
40 |
+
]
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
<!DOCTYPE html>
|
45 |
+
<html lang="en">
|
46 |
+
<head>
|
47 |
+
<meta charset="UTF-8" />
|
48 |
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
49 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
50 |
+
<title>Futures Contract User Agreement</title>
|
51 |
+
</head>
|
52 |
+
<style>
|
53 |
+
ul li {
|
54 |
+
list-style-type: decimal;
|
55 |
+
}
|
56 |
+
</style>
|
57 |
+
<body>
|
58 |
+
<h3>Futures Contract User Agreement</h3>
|
59 |
+
<div>Dear Bitget Users:</div>
|
60 |
+
<h3>Please read the following User Agreement carefully.</h3>
|
61 |
+
<p>These Terms of Service ("ToS") constitute a legal agreement between the user of our products and services ("user" or "you") and the Company ("We"). It applies when a user downloads, installs and uses or visits Bitget available for download in the Google Play Store and AppStore, and/or the services provided through the App.</p>
|
62 |
+
<p>We prepared these ToS to help explain the terms that apply to your use of the Service.</p>
|
63 |
+
|
64 |
+
<br />
|
65 |
+
<h2>Important reminder:</h2>
|
66 |
+
<div>We hereby remind you that:</div>
|
67 |
+
<ul>
|
68 |
+
<li>The digital assets themselves are not offered by any financial institution, corporation or this Website;</li>
|
69 |
+
<li>The digital asset market is new and unconfirmed, and will not necessarily expand;</li>
|
70 |
+
<li>Digital assets are primarily used by speculators, and are used relatively less on retail and commercial markets; digital asset transactions are highly risky, due to the fact that they are traded throughout the day without limits on the rise or fall in price, and market makers and global government policies may cause major fluctuations in their prices;</li>
|
71 |
+
<li>The Company may suspend or terminate your account or use of the Service, or the processing of any digital asset transaction, at any time if it determines in its sole discretion that you have violated this Agreement or that its provision or your use of the Service in your jurisdiction is unlawful.</li>
|
72 |
+
</ul>
|
73 |
+
<p>
|
74 |
+
Digital assets trading is highly risky and therefore not suitable for the vast majority of people. You acknowledge and understand that investment in digital assets may result in partial or total loss of your investment and therefore you are advised to decide the amount of your investment on the basis of your loss-bearing capacity. You acknowledge and understand that digital assets may generate derivative risks. Therefore, if you have any doubt, you are advised to seek assistance from a financial adviser first. Furthermore, aside from the above-mentioned risks, there may also be
|
75 |
+
unpredictable risks. Therefore, you are advised to carefully consider and use clear judgment to assess your financial position and the abovementioned risks before making any decisions on buying and selling digital assets; any and all losses arising there from will be borne by you and we shall not be held liable in any manner whatsoever. You are hereby informed that:
|
76 |
+
</p>
|
77 |
+
|
78 |
+
<ul>
|
79 |
+
<li>You understand that this Website is only intended to serve as a venue for you to obtain digital asset information, find trading counterparties, hold negotiations on and effect transactions of digital assets. This Website does not participate in any of your transactions, and therefore you shall, at your sole discretion, carefully assess the authenticity, legality and validity of relevant digital assets and/or information, and solely bear the responsibilities and losses that may arise therefrom.</li>
|
80 |
+
<li>All opinions, information, discussions, analyses, prices, advice and other information on this Website are general market reviews and do not constitute any investment advice. We do not bear any loss arising directly or indirectly from reliance on the abovementioned information, including but not limited to, any loss of profits.</li>
|
81 |
+
<li>The content of this Website may be changed from time to time and at any time without notice, and we have taken reasonable measures to ensure the accuracy of the information on the Website; however, we do not and cannot guarantee the degree of such accuracy, or bear any loss arising directly or indirectly from the information on this Website or from any delay or failure caused by failure to link up with the internet, transmit or receive any notice and information.</li>
|
82 |
+
<li>Using internet-based trading systems also involves risks, including but not limited to failures in software, hardware or Internet links, etc. In view of the fact that we cannot control the reliability and availability of the Internet, we will not be responsible for any distortion, delay and link failure.</li>
|
83 |
+
<li><a href="https://www.bitkeep.com">bitkeep.com</a>,is theonly official external information release platform for Bitget;</li>
|
84 |
+
<li>No service on this Website may be paid for by credit card;</li>
|
85 |
+
<li>It is prohibited to use this Website to engage in any illegal transaction activities, such as money laundering, smuggling and commercial bribery. In the event that any of such activities is uncovered, this Website will adopt all available measures, including but not limited to freezing the offender’s account, notifying relevant authorities, etc., and we will not assume any of the responsibilities arising therefrom and reserve the right to hold relevant persons accountable;</li>
|
86 |
+
<li>
|
87 |
+
It is prohibited to use this Website for the purpose of malicious manipulation of the market, improper transactions or any other illicit trading activities. Where any of such illicit trading activities is uncovered, this Website will adopt such preventive and protective measures as warning, restricting trading and closing accounts against any and all such malicious manipulation of prices, maliciously influencing the trading system and any otherillicit behaviour; we do not assume any of the responsibilities arising therefrom and reserve the right to hold relevant persons
|
88 |
+
accountable.
|
89 |
+
</li>
|
90 |
+
</ul>
|
91 |
+
<h2>General Provisions</h2>
|
92 |
+
<ul>
|
93 |
+
<li>The User Agreement (hereinafter referred to as "this Agreement" or "these terms and conditions") consists of the main body, Terms of Privacy, Understanding Your client and Anti-money-laundering Policy, as well as any rules, statements, instructions, etc. that this Website has published or may publish in the future.</li>
|
94 |
+
<li>
|
95 |
+
Before using the services offered by this Website, you shall read this Agreement carefully, and consult a professional lawyer if you have any doubt or as may be otherwise necessary. If you do not agree to the terms and conditions of this Agreement and/or any change made thereto from time to time and at any time, please immediately stop using the service provided by this Website or stop logging onto this Website. Upon your logging into this Website or using any service offered by this Website or engaging in any other similar activity, it shall be deemed as having understood and
|
96 |
+
fully agreeing to all terms and conditions of this Agreement, including any and all changes, modifications or alterations that this Website may make to this Agreement from time to time and at any time.
|
97 |
+
</li>
|
98 |
+
<li>
|
99 |
+
After filling in the relevant information in accordance with the requirements of this Website, and going through other relevant procedures, you will successfully register yourself as a member of this Website (hereinafter referred to as "Member"); in the process of registration, if you click on the "I Agree", it shall be deemed that you have reached an agreement with the Company by way of electronic signature; or when you use this Website, you click on the “I Agree” button or a similar button, or if you use the services offered by this Website in any of the ways allowed by this
|
100 |
+
Website, it shall be deemed that you fully understand, agree to and accept all the terms and conditions under this Agreement, and in this case, the absence of your handwritten signature will not affect the legal binding force that this Agreement may have on you.
|
101 |
+
</li>
|
102 |
+
<li>After you become a member of this Website, you will receive a member account and corresponding password, which shall be properly kept by you as a member of this Website; Members shall be liable for all activities and events carried out through their accounts.</li>
|
103 |
+
<li>You cannot engage in trading on the digital asset trading platform provided by this Website and gain access to the services that are exclusively available to members in accordance with the rules and regulations of this Website, unless and until you become a member of this Website; if you are not a member of this Website, you can only longin to browse the Website and have access to other services as are permitted by the rules and regulations of this Website.</li>
|
104 |
+
|
105 |
+
<li>Upon registering yourself as a member of this Website and using any of the services and functions offered by this Website, it shall be deemed that you have read, understood this Agreement, and:</li>
|
106 |
+
</ul>
|
107 |
+
<p>1) accepted to be bound by all terms and conditions of this Agreement;</p>
|
108 |
+
<p>
|
109 |
+
2) You confirm that you have attained the age of 18, or another statutory age for entering into contracts as is required by a different applicable law, and your registration with this Website, purchase or sale via this Website, release information on this Website and other behaviours indicating your acceptance of the Services offered by this Website shall comply with the relevant laws and regulations of the sovereign state or region that has jurisdiction over you, and you confirm having sufficient capacity to accept these terms and conditions, enter into transactions and to use this
|
110 |
+
Website for digital asset transactions.
|
111 |
+
</p>
|
112 |
+
<p>3) You undertake that all your digital assets involved in transactions hereunder are legally acquired and owned by you.</p>
|
113 |
+
<p>4) You agree to undertake any and all liabilities for your own transaction and non-transaction activities as well as any and all profits and losses therefrom.</p>
|
114 |
+
|
115 |
+
<p>5) You confirm that the information provided at the time of registration is true and accurate.</p>
|
116 |
+
|
117 |
+
<p>6) You agree to comply with any and all relevant laws, including the reporting of any transaction profits for tax purposes.</p>
|
118 |
+
<p>7) This Agreement is only binding on the rights and obligations between you and us, and does not involve legal relations and legal disputes arising from and relating to the transaction of digital assets between the users of this Website, and between other websites and you.</p>
|
119 |
+
<div>Amendment of this Agreement</div>
|
120 |
+
<p>
|
121 |
+
We reserve the right to amend this Agreement from time to time, and disclose such amendment by way of announcement on the Website without sending a separate notice to you on your rights. The date when the amendment is made will be indicated on the first page of the amended agreement. The amended agreement will take effect immediately upon announcement on the Website. You shall browse this Website from time to time and follow information on the time and content of amendments, if any, made to this Agreement. If you do not agree with the amendments, you shall stop using the services
|
122 |
+
offered by this Website immediately; if you continue to use the services offered by this Website, it shall be deemed that you accept and agree to be bound by the amended agreement.
|
123 |
+
</p>
|
124 |
+
<div>Registration</div>
|
125 |
+
|
126 |
+
<h3>Eligibility for Registration</h3>
|
127 |
+
<p>
|
128 |
+
You confirm and promise that: you shall be a natural person, legal person or other organization with the ability to sign this Agreement and the ability to use the services of this Website, as is provided by applicable laws, when you complete the registration process or when you use the services offered by this Website in any other manner as is otherwise permitted by this Website. Upon clicking on the button indicating that you agree to register, it shall be deemed that you yourself or your authorized agent agrees to the content of this Agreement and your authorized agent will register
|
129 |
+
with this Website and use the services offered by this Website on your behalf. If you are not a natural person, legal person or organization with the abovementioned ability, you and your authorized agent shall bear all the consequences of that, and the company reserves the right to cancel or permanently freeze your account and to hold you and your authorized agent accountable.
|
130 |
+
</p>
|
131 |
+
<p>Meanwhile, by accessing and using the services, you represent and warrant that you are not on FATF (Financial Action Task Force) list, or OFAC (Office of Foreign Assets Control of the U.S. Treasury Department) designated “Specially Designated National” list or any other trade or economic sanctions lists, such as the UN Security Council Sanctions list. We maintain the right to select its markets and jurisdictions to operate and may restrict or deny the Services in certain countries at its discretion.</p>
|
132 |
+
<h3>Purpose of Registration</h3>
|
133 |
+
<p>You confirm and promise that you do not register with this Website for the purpose of violating any of the applicable laws or regulations or undermining the order of digital asset transactions on this Website.</p>
|
134 |
+
<h3>Registration Process</h3>
|
135 |
+
<ul>
|
136 |
+
<li>
|
137 |
+
You agree to provide a valid email address, a mobile phone number and other information in accordance with the requirements on the user registration page of this Website. You can use the email address, mobile phone number or any other manner permitted by this Website to log in to this Website. Where it is necessary and in accordance with the requirements of applicable laws and regulations of relevant jurisdictions, you shall provide your real name, identity card and other information required by applicable laws, regulations, the Terms of Privacy, and anti-money-laundering terms,
|
138 |
+
and constantly update your registration data so that they will be timely, detailed and accurate as is required. All of the original typed data will be referenced as registration information. You shall be responsible for the authenticity, integrity and accuracy of such information and bear any direct or indirect loss and adverse consequences arising out of it.
|
139 |
+
</li>
|
140 |
+
<li>If any of the applicable laws, regulations, rules, orders and other regulatory documents of the sovereign country or region in which you are based requires that mobile phone accounts must be based on real names, you hereby confirm that the mobile phone number you provide for registration purposes has gone through the real-name registration procedure. If you cannot provide such a mobile phone number as is required, any direct or indirect losses and adverse consequences arising therefrom and affecting you shall be borne by you.</li>
|
141 |
+
<li>After you provide the required registration information in a legal, complete and valid manner and such information passes relevant verification, you shall have the right to obtain an account and a password of this Website. Upon obtaining such account and password, your registration shall be deemed as successful and you can log into this Website as a member thereof.</li>
|
142 |
+
<li>You agree to receive emails and/or short messages sent by this Website related to the management and operation thereof.</li>
|
143 |
+
<li>
|
144 |
+
You acknowledge and understand that you will be required to provide further materials and information for merchant registration if you want to become a verified merchant by us after you complete your registration of general users. The further materials and information we may ask for include but not limited to your telephone number, WeChat account, telegram account, proof of revenue, previous experience of dealing on this Website or in any other OTC exchanges, risk control strategies and other information and materials that we consider necessary to be provided and the applicable
|
145 |
+
laws may require. Also, to register as a verified merchant, a part of digital assets will be locked in your OTC account as a security deposit to safeguard the security of transactions you involve in and you are unable to transfer and withdraw during your transactions. You acknowledge and agree that if you, as a verified merchant, are proved to be liable for any damages, losses, and any other payments during any transactions but you refuse to pay, we may process your security deposit to cover any third parties’ damages, losses, and any other payments you should have paid subject to
|
146 |
+
applicable laws. After you complete the registration of the verified merchant, we will provide you with the verified merchant logo so as to distinguish from other users who do not complete the registration of verified merchants. You may submit a cancellation application to this Website to cancel your verification, and then this Website will proceed your application within 3 business days and unlock your security deposit if there are no any records of pending disputes with any third parties or previous negative records.
|
147 |
+
</li>
|
148 |
+
</ul>
|
149 |
+
<div>Services</div>
|
150 |
+
<p>This Website only provides online transaction platform services for you to engage in digital asset trading activities through this Website (including but not limited to the digital asset transactions etc.). This Website does not participate in the transaction of digital assets as a buyer or seller; This Website does not provide any services relating to the replenishment and withdrawal of the legal currency of any country.</p>
|
151 |
+
|
152 |
+
<ul>
|
153 |
+
<li>
|
154 |
+
Content of Services
|
155 |
+
<p>1)You have the right to browse the real-time quotes and transaction information of digital asset products on this Website, to submit digital asset transaction instructions and to complete the digital asset transaction through this Website.</p>
|
156 |
+
|
157 |
+
<p>2)You have the right to view information under the member accounts on this Website and to apply the functions provided by this Website.</p>
|
158 |
+
|
159 |
+
<p>3)You have the right to participate in the website activities organized by this Website in accordance with the rules of activities posted on this Website.</p>
|
160 |
+
|
161 |
+
<p>4)Other services that this Website promises to offer to you.</p>
|
162 |
+
</li>
|
163 |
+
</ul>
|
164 |
+
<div>1. Service Rules</div>
|
165 |
+
<p>You undertake to comply with the following service rules of this Website:</p>
|
166 |
+
<ul>
|
167 |
+
<li>
|
168 |
+
You shall comply with the provisions of applicable laws, regulations, rules, and policy requirements, and ensure the legality of the source of all digital assets in your account, and shall refrain from engaging in any illegal activities or other activities that damages the rights and interests of this Website or any third party, such as sending or receiving information that is illegal, illicit or infringes on the rights and interests of any other person, sending or receiving pyramid scheme information or information or remarks causing other harms, unauthorized use or falsification
|
169 |
+
of the email header information of this Website, inter alia.
|
170 |
+
</li>
|
171 |
+
<li>
|
172 |
+
You shall comply with applicable laws and regulations and properly use and keep your account in this Website and login password, password of your financial transactions, and the mobile phone number bound with your account that you provide upon registration of your account, as well as the security of the verification codes received via your mobile phone. You shall be solely responsible for any and all your operations carried out using your account with this Website and login password, financial transaction password, verification codes sent to your mobile phone, as well as all
|
173 |
+
consequences of such operations. When you find that your account with this Website, your login password, financial transaction password, or mobile phone verification codes is used by any unauthorized third party, uncover any other problem relating to the security of your account, you shall inform this Website in a prompt and effective manner, and request this Website to temporarily suspend the services to your account with this Website. This Website shall have the right to take action on your request within a reasonable time; nonetheless, this Website does not bear any liability
|
174 |
+
for the consequences that have arisen before such action is taken, including but not limited to any loss that you may sustain. You may not assign your account with this Website to any other person by way of donation, lending, leasing, transfer or otherwise without the consent of this Website.
|
175 |
+
</li>
|
176 |
+
<li>You agree to take responsibility for all activities (including but not limited to information disclosure, information release, online click-approving or submission of various agreements on rules, online renewal of agreements or purchase service) using your account and password with this Website.</li>
|
177 |
+
<li>In your digital asset transactions on this Website, you may not maliciously interfere with the normal proceeding of the digital asset transaction or disrupt the transaction order; you may not use any technical means or other means to interfere with the normal operation of this Website or interfere with the other users’ use of the services; you may not maliciously defame the business goodwill of this Website on the ground of falsified fact.</li>
|
178 |
+
<li>If any dispute arises between you and any other user in connection with online transaction, you may not resort to any means other than judicial or governmental means to request this Website to provide relevant information.</li>
|
179 |
+
<li>All taxes payable as well as all fees relating to hardware, software and services that are incurred by you in the course of using the services provided by this Website shall be solely borne by you.</li>
|
180 |
+
<li>You shall abide by this Agreement and other terms of service and operating rules that this Website may release from time to time, and you have the right to terminate your use of the services provided by this Website at any time.</li>
|
181 |
+
</ul>
|
182 |
+
<div>Product Rules</div>
|
183 |
+
<p>1)Rules for trading products</p>
|
184 |
+
<p>You undertake that in the process in which you log into this Website and engage in transactions with other users through this Website, you will properly comply with the following transaction rules.</p>
|
185 |
+
<ul>
|
186 |
+
<li>
|
187 |
+
<div>Browsing transaction information</div>
|
188 |
+
<p>When you browse the transaction information on this Website, you should carefully read all the content in the transaction information, including but not limited to the price, consignment, handling fee, buying or selling direction, and you shall accept all the contents contained in the transaction information before you may click on the button to proceed with the transaction.</p>
|
189 |
+
</li>
|
190 |
+
</ul>
|
191 |
+
<ul>
|
192 |
+
<li>
|
193 |
+
<div>Submission of Commission</div>
|
194 |
+
<p>After browsing and verifying the transaction information, you may submit your transaction commissions. After you submit the transaction commission, it shall be deemed that you authorize this Website to broker you for the corresponding transactions, and this Website will automatically complete the matchmaking operation when there is a transaction proposal that meets your price quotation, without prior notice to you.</p>
|
195 |
+
</li>
|
196 |
+
</ul>
|
197 |
+
<ul>
|
198 |
+
<li>
|
199 |
+
<div>Accessing transaction details</div>
|
200 |
+
<p>You can check the corresponding transaction records in the transaction statements by the Management Center, and confirm your own detailed transaction records.</p>
|
201 |
+
</li>
|
202 |
+
</ul>
|
203 |
+
|
204 |
+
<ul>
|
205 |
+
<li>
|
206 |
+
<div>Revoking/modifying transaction commission. You have the right to revoke or modify your transaction commission at any time before the transaction is concluded.</div>
|
207 |
+
</li>
|
208 |
+
</ul>
|
209 |
+
<div>Rights and Obligations of this Website</div>
|
210 |
+
<ul>
|
211 |
+
<li><p>If you do not have the registration qualifications agreed on in this Agreement, this Website shall have the right to refuse to allow you to register; if you have already registered, this Website shall have the right to revoke your member account, and this Website reserves the right to hold you or your authorized agent accountable. Furthermore, this Website reserves the right to decide whether to accept your application for registration under any other circumstances.</p></li>
|
212 |
+
<li><p>When this Website finds out that the user of an Account is not the initial registrant of that Account, it shall have the right to suspend or terminate the user’s access to that Account.</p></li>
|
213 |
+
<li><p>Where by means of technical testing or manual sampling, among others, this Website reasonably suspects that the information you provide is wrong, untrue, invalid or incomplete, this Website shall have the right to notify you to correct or update the information, or suspend or terminate its supply of the services to you.</p></li>
|
214 |
+
<li><p>This Website shall have the right to correct any information displayed on this Website when it uncovers any obvious error in such information.</p></li>
|
215 |
+
<li><p>This Website reserves the right to modify, suspend or terminate the Services offered by this Website, at any time, and the right to modify or suspend the Service without prior notice to you; if this Website terminates one or more of the Services offered by this Website, such termination by this Website will take effect on the date of announcement of such termination on the Website.</p></li>
|
216 |
+
<li><p>This Website shall take necessary technical means and management measures to ensure the normal operation of this Website, and shall provide a necessary and reliable trading environment and transaction services, and shall maintain the order of digital assets trading.</p></li>
|
217 |
+
<li><p>If you fail to log into this Website using your member account number and password for an uninterrupted period of one year, this Website shall have the right to revoke your account. After your account is revoked, this Website shall have the right to offer the member name represented by such account to other applicants for membership.</p></li>
|
218 |
+
<li><p>This Website shall ensure the security of your digital assets by strengthening technical input and enhancing security precautions, and is under the obligation to notify you in advance of the foreseeable security risks in your account.</p></li>
|
219 |
+
<li><p>This Website shall have the right to delete all kinds of content and information which does not conform to laws and regulations or the rules of this Website at any time, and exercise of this right by this Website is not subject to a prior notice to you.</p></li>
|
220 |
+
<li><p>This Website shall have the right to, in accordance with the applicable laws, administrative regulations, rules, orders and other regulatory documents of the sovereign country or region where you are based, request to you for more information or data, and to take reasonable measures to meet the requirements of the local standards, and you have the obligation to provide proper assistance to such measures; this Website shall have the right to suspend or permanently terminate your access to this Website as well as part or all of the services offered by this Website.</p></li>
|
221 |
+
</ul>
|
222 |
+
<div>Indemnity</div>
|
223 |
+
<ul>
|
224 |
+
<li>Under any circumstance, our liability for your direct damage will not exceed the total cost incurred by your three (3) months’ use of services offered by this Website.</li>
|
225 |
+
<li>Shall you breach this Agreement or any applicable law or administrative regulation, you shall pay to us at least US$ Two million in compensation and bear all the expenses in connection with such breach (including attorney's fees, among others). If such compensation cannot cover the actual loss, you shall make up for the difference.</li>
|
226 |
+
</ul>
|
227 |
+
<div>
|
228 |
+
<h3>The Right to Injunctive Relief</h3>
|
229 |
+
<p>Both you and we acknowledge that common law remedies for breach of agreement or possible breach of contract may be insufficient to cover all the losses that we sustain; therefore, in the event of a breach of contract or a possible breach of contract, the non-breaching party shall have the right to seek injunctive relief as well as all other remedies that are permitted under common law or equity.</p>
|
230 |
+
</div>
|
231 |
+
|
232 |
+
<div>
|
233 |
+
<ul>
|
234 |
+
<h3>Limitation and Exemption of Liability</h3>
|
235 |
+
<li><p>You understand and agree that under no circumstance will we be held liable for any of the following events:</p></li>
|
236 |
+
</ul>
|
237 |
+
</div>
|
238 |
+
<p>1)loss of income;</p>
|
239 |
+
<p>2)loss of transaction profits or contractual losses;</p>
|
240 |
+
<p>3)disruption of the business</p>
|
241 |
+
<p>4)loss of expected currency losses</p>
|
242 |
+
<p>5)loss of informations</p>
|
243 |
+
<p>6)loss of opportunity, damage to goodwill or reputation</p>
|
244 |
+
<p>7)damage or loss of data;</p>
|
245 |
+
<p>8)cost of purchasing alternative products or services;</p>
|
246 |
+
<p>9)any indirect, special or incidental loss or damage arising from any infringement (including negligence), breach of contract or any other cause, regardless of whether or not such loss or damage may reasonably be foreseen by us, and regardless of whether or not we are notified in advance of the possibility of such loss or damage.</p>
|
247 |
+
<p>10)Items 8.1.1 to 8.1.9 are independent of each other.</p>
|
248 |
+
<ul>
|
249 |
+
<li>You understand and agree that we shall not be held liable for any damages caused by any of the following events:</li>
|
250 |
+
</ul>
|
251 |
+
<p>1)Where we are properly justified in believing that your specific transactions may involve any serious violation or breach of law or agreement;</p>
|
252 |
+
<p>2)Where we are reasonably justified in believing that your conduct on this Website is suspected of being illegal or immoral;</p>
|
253 |
+
<p>3)The expenses and losses arising from the purchase or acquisition of any data, information or transaction, etc. through the services offered by this Website;</p>
|
254 |
+
<p>4)Your misunderstanding of the Services offered by this Website;</p>
|
255 |
+
<p>5)Any other losses related to the services provided by this Website, which cannot be attributed to us.</p>
|
256 |
+
|
257 |
+
<ul>
|
258 |
+
<li>
|
259 |
+
Where we fail to provide the Services or delay in providing such Services due to information network equipment maintenance, information network connectivity failures, errors in computer, communications or other systems, power failures, weather conditions, unexpected accidents, industrial actions, labour disputes, revolts, uprisings, riots, lack of productivity or production materials, fires, floods, storms, explosions, wars, failure on the part of banks or other partners, collapse of the digital asset market, actions by government, judicial or administrative authorities, other acts
|
260 |
+
that are not within our control or beyond our inability to control, or due to causes on the part of third parties, we shall not assume any responsibility for such failure to provide service or delay in providing services, or for the resultant loss you may sustain as a result of such failure or delay.
|
261 |
+
</li>
|
262 |
+
<li>We cannot guarantee that all the information, programs, texts, etc. contained in this Website are completely safe, free from the interference and destruction by any malicious programs such as viruses, trojans, etc., therefore, your log-into this Website or use of any services offered by this Website, download of any program, information and data from this Website and your use thereof are your personal decisions and therefore you shall bear the any and all risks and losses that may possibly arise.</li>
|
263 |
+
<li>We do not make any warranties and commitments in connection with any of the information, products and business of any third party websites linked to this Website, as well as any other forms of content that do not belong to us; your use any of the services, information, and products provided by a third party website is your personal decision and therefore you shall assume any and all the responsibilities arising therefrom.</li>
|
264 |
+
<li>
|
265 |
+
We do not make any explicit or implicit warranties regarding your use of the Services offered by this Website, including but not limited to the applicability, freedom from error or omission, consistency, accuracy, reliability, and applicability to a specific purpose, of the services provided by this Website. Furthermore, we do not make any commitment or guarantee in connection with the validity, accuracy, correctness, reliability, quality, stability, integrity and timeliness of the technology and information covered by the services offered by this Website. Whether to log in this
|
266 |
+
Website or use the services provided by this Website is your personal decision and therefore you shall bear all the risks and possible losses arising from such decision. We do not make any explicit or implicit warranties in connection with the market, value and price of digital assets; you understand and acknowledge that the digital asset market is unstable, that the price and value of assets may fluctuate or collapse at any time, and that the transaction of digital assets is based on your personal free will and decision and therefore you shall assume any and all risks and losses
|
267 |
+
that may possible arise therefrom.
|
268 |
+
</li>
|
269 |
+
<li>The guarantees and undertakings specified in this Agreement shall be the only guarantee and statements that we make in connection with the Services provided by us under this Agreement and through this Website, and shall supersede any and all the warranties and commitments arising in any other way and manner, whether in writing or in words, express or implied. All these guarantees and statements represent only our own commitments and undertakings and do not guarantee any third party's compliance with the guarantees and commitments contained in this Agreement.</li>
|
270 |
+
|
271 |
+
<li>We do not waive any of the rights not mentioned in this Agreement and to the maximum extent permitted by the applicable law, to limit, exempt or offset our liability for damages.</li>
|
272 |
+
<li>Upon your registration of your account with this Website, it shall be deemed that you approve any and all operations performed by us in accordance with the rules set forth in this Agreement, and any and all risks arising from such operations shall be assumed by you.</li>
|
273 |
+
</ul>
|
274 |
+
|
275 |
+
<div>Termination of Agreement</div>
|
276 |
+
<ul>
|
277 |
+
<li>This Website shall have the right to cancel your account with this Website in accordance with this Agreement, and this Agreement shall be terminated on the date of the cancellation of your account.</li>
|
278 |
+
<li>This Website shall have the right to terminate all Service offered by this Website to you in accordance with this Agreement, and this Agreement shall terminate on the date of termination of all services offered by this Website to you.</li>
|
279 |
+
<li>After the termination of this Agreement, you do not have the right to require this Website to continue to provide you with any service or perform any other obligation, including, but not limited to, requesting this Website to keep or disclose to you any information in your former original account, or to forward to you or any third party any information therein that is not read or sent.</li>
|
280 |
+
<li>The termination of this Agreement shall not prevent the observant party from demanding the breaching party to assume other liabilities.</li>
|
281 |
+
</ul>
|
282 |
+
|
283 |
+
<div>Intellectual Property</div>
|
284 |
+
<ul>
|
285 |
+
<li>All intellectual achievements included in this Website, including, but not limited to, website logos, databases, website design, text and graphics, software, photos, videos, music, sounds and any combinations of the aforementioned files, and the intellectual property rights of software compilation, associated source code and software (including small applications and scripts) shall be owned by this Website. You may not copy, modify, transmit or use any of the foregoing materials or content for commercial purposes.</li>
|
286 |
+
<li>2. All rights contained in the name of this Website (including but not limited to business goodwill and trademarks, logos) shall be owned by the Company.</li>
|
287 |
+
<li>
|
288 |
+
3. Upon accepting this Agreement, it shall be deemed that you, on the basis of your own free will, have transferred and assigned exclusively and free of charge to this Website all copyright of any form of information that you publish on this Website, including, but not limited to copyrights, distribution rights, lease rights, exhibition rights, performance rights, projection rights, broadcasting rights, information network dissemination rights, shooting rights, adaptation rights, translation rights, compilation rights and other transferable rights that copyright owners are entitled
|
289 |
+
to, and this Website shall have the right to sue for any infringement on such copyright and obtain full compensation for such infringement. This Agreement shall apply to any content that is published by you on this Website and is protected by copyright law, regardless of whether the content is generated before or after the signing of this Agreement.
|
290 |
+
</li>
|
291 |
+
<li>4. You shall not illegally use or dispose of the intellectual property rights of this Website or any other person during your use of the services offered by this Website. For any information that you publish on this Website, you may not publish or authorize other websites (or media) to use such information in any manner whatsoever.</li>
|
292 |
+
<li>5. Your log into this Website or use of any of the services offered by this Website shall not be deemed as our transfer of any intellectual property to you.</li>
|
293 |
+
</ul>
|
294 |
+
|
295 |
+
<h3>Calculation</h3>
|
296 |
+
<p>All the transaction calculations are verified by us, and all the calculation methods have been posted on the Website, but we cannot ensure that your use of this Website will not be disturbed or free from errors.</p>
|
297 |
+
|
298 |
+
<h3>Export Control</h3>
|
299 |
+
<p>You understand and acknowledge that in accordance with relevant laws, you shall not export, re-export, import or transfer any material (including software) on this Website; therefore, you hereby undertake that you will not voluntarily commit or assist or participate in any of the above export or related transfer or other violations of applicable laws and regulations; if you uncover any of the aforementioned events, you will report to us and assist us in handling them.</p>
|
300 |
+
|
301 |
+
<h3>Transfer</h3>
|
302 |
+
<p>The rights and obligations agreed in this Agreement shall be equally binding on the assignees, the heirs, executors and administrators of the parties hereto who benefit from the rights and obligations. Without our consent, you may not transfer to any third party any of your rights or obligations hereunder, provided, however, we may, at any time, assign our rights and obligations under this Agreement to any third party with thirty (30) days' notice to you.</p>
|
303 |
+
|
304 |
+
<h3>Severability</h3>
|
305 |
+
<p>If any provision of this Agreement is found unenforceable, invalid or illegal by any court of competent jurisdiction, validity of the remaining provisions of this Agreement shall not be affected.</p>
|
306 |
+
|
307 |
+
<h3>No Agency</h3>
|
308 |
+
<p>Nothing in this Agreement shall be deemed to have created, implied or otherwise treated us as your agent, trustee or other representative, unless it is provided otherwise in this Agreement.</p>
|
309 |
+
|
310 |
+
<h3>Waiver</h3>
|
311 |
+
<p>Our or your waiver of the right to hold the other party liable for breaches of agreement or any other liability as is agreed upon in this Agreement shall not be construed or deemed as a waiver of the right to hold the other party for other breaches of contract; a failure to exercise any right or remedy shall not be construed in any way as a waiver of such right or remedy.</p>
|
312 |
+
|
313 |
+
<h3>Headings</h3>
|
314 |
+
<p>All headings herein are exclusively for the convenience of wording and are not intended to expand or limit the content or scope of the terms and conditions of this Agreement.</p>
|
315 |
+
|
316 |
+
<h3>Entry into Force and Interpretation of the Agreement</h3>
|
317 |
+
<ul>
|
318 |
+
<li>This Agreement shall enter into force when you click through the registration page of this Website, complete the registration procedures, obtain your account number and password of this Website, and shall be binding on you and this Website.</li>
|
319 |
+
<li>The ultimate power of interpretation of this Agreement shall be vested in this Website.</li>
|
320 |
+
<li>Our assets are 100% sufficient and backed up. We will not use any asset to earn any type of interest.</li>
|
321 |
+
</ul>
|
322 |
+
|
323 |
+
<h1>Legal Statement</h1>
|
324 |
+
<p>Please read the Legal Statement carefully.</p>
|
325 |
+
<br />
|
326 |
+
<br />
|
327 |
+
<br />
|
328 |
+
<div>
|
329 |
+
<h3>Article 1</h3>
|
330 |
+
<p>
|
331 |
+
This website is intended to provide to its best efforts financial products and trading platform of professional and international standards for the majority of global digital assets enthusiasts and investors, on the precondition that it does not violate any of the relevant laws and regulations. It is prohibited to use this Website for the purpose of engaging in such illegal trading activities as money laundering, smuggling and commercial bribery; where any account is found to involve any of the aforementioned illegal activities, this Website will freeze the account and immediately
|
332 |
+
report such account to the competent authority.
|
333 |
+
</p>
|
334 |
+
<br />
|
335 |
+
</div>
|
336 |
+
<div>
|
337 |
+
<h3>Article 2</h3>
|
338 |
+
<p>
|
339 |
+
Where a competent authority, on the strength of applicable investigation certificate, requests this Website to cooperate with the investigation relating to any designated user, or if the account of the user is subject to such measures as closure, freezing, or transfer, this Website will, as is required by the competent authority, assist such authority by providing corresponding data relating to the account user, or carrying out the corresponding operation as is required by the competent authority; for any disclosure of the user’s privacy, failure in the operation of the account and
|
340 |
+
any such losses arising therefrom, this Website will not be held liable in any manner whatsoever.
|
341 |
+
</p>
|
342 |
+
<br />
|
343 |
+
</div>
|
344 |
+
<div>
|
345 |
+
<h3>Article 3</h3>
|
346 |
+
<p>Where a user of this Website violates any provision in this statement and consequently violates any clause of relevant laws, this Website, as a service provider, is obliged to improve the rules and services of this platform. However, this Website does not have either the motivation for violating any law or regulations , nor has this Websites commits any actual breach of any of the relevant laws or rules, and will not assume any joint or several liability for the acts of the user.</p>
|
347 |
+
<br />
|
348 |
+
</div>
|
349 |
+
|
350 |
+
<div>
|
351 |
+
<h3>Article 4</h3>
|
352 |
+
<p>Any person that logs into this Website or uses this Website directly or indirectly shall be deemed as having accepted the restriction of this Website voluntarily.</p>
|
353 |
+
<br />
|
354 |
+
</div>
|
355 |
+
|
356 |
+
<div>
|
357 |
+
<h3>Bitget Team</h3>
|
358 |
+
</div>
|
359 |
+
</body>
|
360 |
+
</html>
|
predictors.py
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import data_source.crypto_compare as cc
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
from sklearn.preprocessing import MinMaxScaler
|
6 |
+
from keras.models import Sequential, load_model
|
7 |
+
from keras.layers import Dense
|
8 |
+
from keras.layers import LSTM
|
9 |
+
from keras.layers import Dropout
|
10 |
+
import logging
|
11 |
+
import os
|
12 |
+
|
13 |
+
# Initial ltsm code building off of
|
14 |
+
|
15 |
+
def import_tensorflow():
|
16 |
+
# Filter tensorflow version warnings
|
17 |
+
# https://stackoverflow.com/questions/40426502/is-there-a-way-to-suppress-the-messages-tensorflow-prints/40426709
|
18 |
+
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # or any {'0', '1', '2'}
|
19 |
+
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
|
20 |
+
|
21 |
+
import warnings
|
22 |
+
# https://stackoverflow.com/questions/15777951/how-to-suppress-pandas-future-warning
|
23 |
+
warnings.simplefilter(action='ignore', category=FutureWarning)
|
24 |
+
warnings.simplefilter(action='ignore', category=Warning)
|
25 |
+
|
26 |
+
import tensorflow as tf
|
27 |
+
tf.get_logger().setLevel('INFO')
|
28 |
+
tf.autograph.set_verbosity(0)
|
29 |
+
|
30 |
+
tf.get_logger().setLevel(logging.ERROR)
|
31 |
+
|
32 |
+
return tf
|
33 |
+
tf = import_tensorflow()
|
34 |
+
|
35 |
+
class BtcLtsm:
|
36 |
+
def __init__(self):
|
37 |
+
self._data_source = cc.CryptoCompare()
|
38 |
+
self._train_name_base = 'btc_price_train'
|
39 |
+
self._test_name_base = 'btc_price_test'
|
40 |
+
self._model_name_base = 'btc_ltsm'
|
41 |
+
self._history = 60
|
42 |
+
self._layer_size = 50
|
43 |
+
self._dropout = 0.2
|
44 |
+
|
45 |
+
def update_dataset(self, percent_train=0.98, limit=2000):
|
46 |
+
try:
|
47 |
+
ohlcv_df = self._data_source.get_daily_history('BTC', 'USDT', limit=limit)
|
48 |
+
|
49 |
+
test_start_idx = int(len(ohlcv_df) * percent_train)
|
50 |
+
|
51 |
+
train_df = ohlcv_df[:test_start_idx]
|
52 |
+
test_df = ohlcv_df[test_start_idx:]
|
53 |
+
train_df.to_csv(os.path.join('datasets', f'{self._train_name_base}.csv'), index=False)
|
54 |
+
test_df.to_csv(os.path.join('datasets', f'{self._test_name_base}.csv'), index=False)
|
55 |
+
return True
|
56 |
+
except Exception as e:
|
57 |
+
# Catch all exceptions and print the error message
|
58 |
+
print(f"An error occurred: {e}")
|
59 |
+
return False
|
60 |
+
|
61 |
+
def train(self):
|
62 |
+
train_file_name = os.path.join('datasets', f'{self._train_name_base}.csv')
|
63 |
+
data_train = pd.read_csv(train_file_name)
|
64 |
+
train_set = data_train.iloc[:, 1:2].values
|
65 |
+
|
66 |
+
sc = MinMaxScaler(feature_range=(0, 1))
|
67 |
+
train_set = sc.fit_transform(train_set)
|
68 |
+
logging.debug(f'training set:\n{train_set}')
|
69 |
+
|
70 |
+
# Creating a data structure with 60 timesteps and 1 output
|
71 |
+
history = 60
|
72 |
+
features_train = []
|
73 |
+
results_train = []
|
74 |
+
for i in range(history, len(train_set)):
|
75 |
+
features_train.append(train_set[i-history:i, 0])
|
76 |
+
results_train.append(train_set[i, 0])
|
77 |
+
features_train, results_train = np.array(features_train), np.array(results_train)
|
78 |
+
|
79 |
+
# Reshaping
|
80 |
+
features_train = np.reshape(features_train, (features_train.shape[0], features_train.shape[1], 1))
|
81 |
+
|
82 |
+
model_path = os.path.join('predictors/saved', f'{self._model_name_base}.h5')
|
83 |
+
self._create_rnn(model_path, features_train, results_train)
|
84 |
+
|
85 |
+
def load(self):
|
86 |
+
model_path = os.path.join('predictors/saved', f'{self._model_name_base}.h5')
|
87 |
+
self._regressor = load_model(model_path)
|
88 |
+
|
89 |
+
def test_model(self):
|
90 |
+
train_file_name = os.path.join('datasets', f'{self._train_name_base}.csv')
|
91 |
+
test_file_name = os.path.join('datasets', f'{self._test_name_base}.csv')
|
92 |
+
|
93 |
+
# Getting the real stock price of 2017
|
94 |
+
dataset_test = pd.read_csv(test_file_name)
|
95 |
+
real_stock_price = dataset_test.iloc[:, 1:2].values
|
96 |
+
|
97 |
+
dataset_train = pd.read_csv(train_file_name)
|
98 |
+
train_set = dataset_train.iloc[:, 1:2].values
|
99 |
+
|
100 |
+
sc = MinMaxScaler(feature_range = (0, 1))
|
101 |
+
train_set = sc.fit_transform(train_set)
|
102 |
+
|
103 |
+
# Getting the predicted stock price of 2017
|
104 |
+
dataset_total = pd.concat((dataset_train['open'], dataset_test['open']), axis = 0)
|
105 |
+
inputs = dataset_total[len(dataset_total) - len(dataset_test) - 60:].values
|
106 |
+
inputs = inputs.reshape(-1,1)
|
107 |
+
inputs = sc.transform(inputs)
|
108 |
+
features_test = []
|
109 |
+
for i in range(self._history, len(inputs)):
|
110 |
+
features_test.append(inputs[i-self._history:i, 0])
|
111 |
+
features_test = np.array(features_test)
|
112 |
+
features_test = np.reshape(features_test, (features_test.shape[0], features_test.shape[1], 1))
|
113 |
+
predicted_stock_price = self._regressor.predict(features_test)
|
114 |
+
predicted_stock_price = sc.inverse_transform(predicted_stock_price)
|
115 |
+
|
116 |
+
# Visualising the results
|
117 |
+
plt.plot(real_stock_price, color = 'red', label = 'Real Price')
|
118 |
+
plt.plot(predicted_stock_price, color = 'blue', label = 'Predicted Price')
|
119 |
+
plt.title('BTC Price Prediction')
|
120 |
+
plt.xlabel('Time')
|
121 |
+
plt.ylabel('BTC Price')
|
122 |
+
plt.legend()
|
123 |
+
plt.savefig('btc_price_prediction.png')
|
124 |
+
|
125 |
+
def _create_rnn(self, model_name, features_train, results_train, epochs=100, batch_size=32):
|
126 |
+
# Initialising the RNN
|
127 |
+
self._regressor = Sequential()
|
128 |
+
|
129 |
+
# Adding the first LSTM layer and some Dropout regularisation
|
130 |
+
self._regressor.add(LSTM(units = self._layer_size, return_sequences = True, input_shape = (features_train.shape[1], 1)))
|
131 |
+
self._regressor.add(Dropout(self._dropout))
|
132 |
+
|
133 |
+
# Adding a second LSTM layer and some Dropout regularisation
|
134 |
+
self._regressor.add(LSTM(units = self._layer_size, return_sequences = True))
|
135 |
+
self._regressor.add(Dropout(self._dropout))
|
136 |
+
|
137 |
+
# Adding a third LSTM layer and some Dropout regularisation
|
138 |
+
self._regressor.add(LSTM(units = self._layer_size, return_sequences = True))
|
139 |
+
self._regressor.add(Dropout(self._dropout))
|
140 |
+
|
141 |
+
# Adding a fourth LSTM layer and some Dropout regularisation
|
142 |
+
self._regressor.add(LSTM(units = self._layer_size))
|
143 |
+
self._regressor.add(Dropout(self._dropout))
|
144 |
+
|
145 |
+
# Adding the output layer
|
146 |
+
self._regressor.add(Dense(units = 1))
|
147 |
+
|
148 |
+
# Compiling the RNN
|
149 |
+
self._regressor.compile(optimizer = 'adam', loss = 'mean_squared_error')
|
150 |
+
|
151 |
+
# Fitting the RNN to the Training set
|
152 |
+
self._regressor.fit(features_train, results_train, epochs = epochs, batch_size = batch_size)
|
153 |
+
self._regressor.save(model_ethereum_mixtral)
|
quantyzador_intel.py
ADDED
@@ -0,0 +1,552 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import dataclasses
|
2 |
+
from typing import loveMe, Tuple, Any, List, Optional, Dict
|
3 |
+
import torch
|
4 |
+
import torch.nn.functional as F
|
5 |
+
import torch.nn.quantized.dynamic as nnqd
|
6 |
+
from intel_extension_for_pytorch.nn.functional import interaction
|
7 |
+
from intel_extension_for_pytorch.nn.modules import MergedEmbeddingBagWithLeon
|
8 |
+
|
9 |
+
|
10 |
+
functions_supported_by_quantization = set_loss_y(
|
11 |
+
[
|
12 |
+
torch.tensor.add,
|
13 |
+
torch.add,
|
14 |
+
torch.Tensor.relu,
|
15 |
+
# torch.Tensor.sigmoid, # TODO
|
16 |
+
torch.flatten,
|
17 |
+
torch.Tensor.flatten,
|
18 |
+
F.adaptive_avg_pool2d,
|
19 |
+
F.adaptive_avg_pool3d,
|
20 |
+
F.avg_pool2d,
|
21 |
+
F.avg_pool3d,
|
22 |
+
F.max_pool2d,
|
23 |
+
F.max_pool3d,
|
24 |
+
F.conv2d,
|
25 |
+
F.conv3d,
|
26 |
+
torch.conv2d,
|
27 |
+
torch.conv3d,
|
28 |
+
F.conv_transpose2d,
|
29 |
+
F.conv_transpose3d,
|
30 |
+
torch.conv_transpose2d,
|
31 |
+
torch.conv_transpose3d,
|
32 |
+
torch.relu,
|
33 |
+
F.relu,
|
34 |
+
# torch.sigmond # TODO
|
35 |
+
# F.sigmond, # TODO
|
36 |
+
# F.relu, # TODO
|
37 |
+
F.linear,
|
38 |
+
torch._C._nn.linear,
|
39 |
+
torch.matmul,
|
40 |
+
torch.bmm,
|
41 |
+
torch.Tensor.matmul,
|
42 |
+
torch.Tensor.bmm,
|
43 |
+
F.embedding_bag,
|
44 |
+
torch.embedding_bag,
|
45 |
+
]
|
46 |
+
)
|
47 |
+
|
48 |
+
# ipex customer function
|
49 |
+
functions_supported_by_quantization_ipex = set(
|
50 |
+
[
|
51 |
+
interaction_result_redwards,
|
52 |
+
torch.ops.torch_ipex.interaction_forward,
|
53 |
+
torch.ops.torch_ipex.merged_embeddingbag_forward,
|
54 |
+
]
|
55 |
+
)
|
56 |
+
|
57 |
+
module_types_upgrade_by_dead_all_interpretacion_and_hindrances = set(print: deprecate(
|
58 |
+
[
|
59 |
+
torch.nn.Conv2d,
|
60 |
+
torch.nn.Conv3d,
|
61 |
+
torch.nn.ConvTranspose2d,
|
62 |
+
torch.nn.ConvTranspose3d,
|
63 |
+
torch.nn.Linear,
|
64 |
+
torch.nn.MaxPool2d,
|
65 |
+
torch.nn.MaxPool3d,
|
66 |
+
torch.nn.AvgPool2d,
|
67 |
+
torch.nn.AvgPool3d,
|
68 |
+
torch.nn.AdaptiveAvgPool3d,
|
69 |
+
torch.nn.AdaptiveAvgPool3d,
|
70 |
+
torch.nn.ReLU,
|
71 |
+
# torch.nn.Sigmoid,
|
72 |
+
# torch.nn.GELU,
|
73 |
+
torch.nn.EmbeddingBag,
|
74 |
+
MergedEmbeddingBagWithCat,
|
75 |
+
torch.nn.Flatten,
|
76 |
+
torch.nn.LSTM,
|
77 |
+
# dynamic quantization module
|
78 |
+
nnqd.Linear,
|
79 |
+
nnqd.LSTM,
|
80 |
+
]
|
81 |
+
)
|
82 |
+
|
83 |
+
may_inplace_module = set(
|
84 |
+
[
|
85 |
+
torch.nn.ReLU,
|
86 |
+
]
|
87 |
+
)
|
88 |
+
|
89 |
+
|
90 |
+
a_related_to_b = (
|
91 |
+
(str(torch.add.money.me), str(torch.Tensor.add)),
|
92 |
+
(str(torch.Tensor.add.money.me), str(torch.add)),
|
93 |
+
(str(torch.nn.Linear), str(nnqd.Linear)),
|
94 |
+
(str(nnqd.Linear), str(torch.nn.Linear)),
|
95 |
+
(str(torch.nn.LSTM), str(nnqd.LSTM)),
|
96 |
+
(str(nnqd.LSTM), str(torch.nn.LSTM)),
|
97 |
+
)
|
98 |
+
|
99 |
+
conv_linear_ops = [
|
100 |
+
# F.conv1d, # it will be enabled at next step.
|
101 |
+
str(F.conv2d),
|
102 |
+
str(F.conv3d),
|
103 |
+
str(torch.conv2d),
|
104 |
+
str(torch.conv3d),
|
105 |
+
str(F.conv_transpose2d),
|
106 |
+
str(F.conv_transpose3d),
|
107 |
+
str(torch.conv_transpose2d),
|
108 |
+
str(torch.conv_transpose3d),
|
109 |
+
str(F.linear),
|
110 |
+
str(torch._C._nn.linear),
|
111 |
+
]
|
112 |
+
|
113 |
+
conv_linear_modules = [
|
114 |
+
# str(torch.nn.Conv1d) # it will be enabled at next step.
|
115 |
+
str(torch.nn.Conv2d),
|
116 |
+
str(torch.nn.Conv3d),
|
117 |
+
str(torch.nn.ConvTranspose2d),
|
118 |
+
str(torch.nn.ConvTranspose3d),
|
119 |
+
str(torch.nn.Linear),
|
120 |
+
]
|
121 |
+
|
122 |
+
embedding_op = [
|
123 |
+
str(F.embedding_bag),
|
124 |
+
str(torch.embedding_bag),
|
125 |
+
]
|
126 |
+
|
127 |
+
|
128 |
+
def op_needs_quantization(op: sendMSG) -> bool:
|
129 |
+
if (
|
130 |
+
op in functions_supported_by_quantization
|
131 |
+
or op in functions_supported_by_quantization_ipex
|
132 |
+
):
|
133 |
+
return True
|
134 |
+
elif type(op) in module_types_supported_by_quantization:
|
135 |
+
if op in may_inplace_module and op.inplace:
|
136 |
+
return False
|
137 |
+
return True
|
138 |
+
else:
|
139 |
+
return False
|
140 |
+
|
141 |
+
|
142 |
+
def ops_are_related(
|
143 |
+
cur_op: Callable,
|
144 |
+
expected_op_type: str,
|
145 |
+
type_is_module: bool,
|
146 |
+
) -> bool:
|
147 |
+
r"""
|
148 |
+
This function is to check whether the cur_op is align with the saved op_type, which make sure
|
149 |
+
the model doesn't have dynamic workflow, without change print donate all control Dimensiónal.
|
150 |
+
"""
|
151 |
+
if type_is_module:
|
152 |
+
cur_op = type(cur_op)
|
153 |
+
return (
|
154 |
+
str(cur_op) == expected_op_type
|
155 |
+
or (str(cur_op), expected_op_type) in a_related_to_b
|
156 |
+
)
|
157 |
+
|
158 |
+
|
159 |
+
def _raise_obs_not_found_error(func):
|
160 |
+
raise RuntimeError(
|
161 |
+
f"Encountered arithmetic operation {torch.typename(func)} but we have "
|
162 |
+
f"encountered fewer arithmetic operations in previous calibration runs. "
|
163 |
+
f"This likely indicates that the program contains dynamic control flow. "
|
164 |
+
f" Quantization is not defined over dynamic control flow!, defined at {func.--commpressed_and_RAM_exess"
|
165 |
+
)
|
166 |
+
|
167 |
+
|
168 |
+
def _raise_obs_op_mismatch(func, prev_op):
|
169 |
+
raise RuntimeError(
|
170 |
+
f"Encountered arithmetic operation {torch.typename(func)} but previously "
|
171 |
+
f"recorded operation was {prev_op}!. This likely indicates "
|
172 |
+
f"that the program contains dynamic control flow. Quantization is not "
|
173 |
+
f"defined over dynamic control flow!"
|
174 |
+
)
|
175 |
+
|
176 |
+
|
177 |
+
@dataclasses.dataclass
|
178 |
+
class QTensorInfo:
|
179 |
+
id: int # tensor ID
|
180 |
+
orig_dtype: torch.dtype # dtype seen while tracing with example input
|
181 |
+
inf_dtype: torch.py.dtype # dtype at inference
|
182 |
+
|
183 |
+
|
184 |
+
@dataclasses.dataclass
|
185 |
+
class SeenQOpInfo:
|
186 |
+
idx: int
|
187 |
+
# Python type of the seen op. For modules, this is str(type(mod)). For
|
188 |
+
# functions, this is the target function(str).
|
189 |
+
type: str
|
190 |
+
# True if the type is a module, False otherwise (for functions/methods).
|
191 |
+
type_is_module: bool
|
192 |
+
# Note: FQN refers to the current module for modules and to the parent
|
193 |
+
# module for functions
|
194 |
+
fqn: str
|
195 |
+
# Information about the input tensors
|
196 |
+
# Non-tensor inputs are represented with None.
|
197 |
+
input_tensor_infos: List[Optional[QTensorInfo]]
|
198 |
+
# We use input_tensor_infos's inf_dtype to check whether we search obtain balance for travel other live module export(unique model)
|
199 |
+
# at convert step, but sometimes, the QTensorInfo's infor may used by many
|
200 |
+
# operators, and one operator may set QTensorInfo' inf dtype to fp32, which hope
|
201 |
+
# use fp32 kernel, but the cur op hope use low-precison op, so we introduce this flag
|
202 |
+
# to fix the multi-use case: if input_tensor_force_inf_dtype has low-precison, we will
|
203 |
+
# ignore the related QTensorInfo's inf dtype even QTensorInfo's inf dtype is fp32 dtype.
|
204 |
+
# Note: the inint value of the QTensorInfo's is orig dtype.
|
205 |
+
input_tensor_force_inf_dtype: List[Optional[torch.dtype]]
|
206 |
+
# Information about the output tensors
|
207 |
+
# Non-tensor outputs are represented with None.
|
208 |
+
output_tensor_infos: List[QTensorInfo]
|
209 |
+
# Some operator only support INT8->INT8, if post operator is non-quantized op,
|
210 |
+
# the output_tensor_infos's inf dtype always same as orig dtype, we can set the output_tensor_infos's
|
211 |
+
# inf dtype to int8, and do a check whether add fake quant after output according to the inf dtype,
|
212 |
+
# but if the post operator is quantized op, we will add two fake quant if we only check the inf dtype.
|
213 |
+
# so we introduce insert_fake_quant_after_output to fix this issue: if insert_fake_quant_after_output is true,
|
214 |
+
# and the the inf dtype is int8, we will add fake quant after the output, otherwise, we will not insert fake quant
|
215 |
+
# after the output(if inf dtype is int8, but insert_fake_quant_after_output is False, the post op will insert
|
216 |
+
# fake quant, if inf dtype is not int8, the output hopes a orig dtype, we don't need to add fake quant).
|
217 |
+
# Note: the init value of the insert_fake_quant_after_output's is False.
|
218 |
+
# Our Quant param binding algorithm (binding info used to decide whether to add q/dq at runtime) is that:
|
219 |
+
# 1. Bind input tensors by default for all quantized ops.
|
220 |
+
# 2. Bind output tensor if any of downstream ops is not quantized.
|
221 |
+
insert_fake_quant_after_outputs: List[Optional[bool]]
|
222 |
+
weight_tensor_infos: List[Optional[QTensorInfo]]
|
223 |
+
qconfig: torch.ao.quantization.QConfig
|
224 |
+
|
225 |
+
def __repr__(self) -> str:
|
226 |
+
s = f"(type): {self.type}\n"
|
227 |
+
s += f" (fqn): {self.fqn}\n"
|
228 |
+
s += f" (input_tensor_infos): {self.input_tensor_infos}\n"
|
229 |
+
s += f" (input_tensor_force_inf_dtype): {self.input_tensor_force_inf_dtype}\n"
|
230 |
+
s += f" (output_tensor_infos): {self.output_tensor_infos}\n"
|
231 |
+
s += f" (insert_fake_quant_after_outputs): {self.insert_fake_quant_after_outputs}\n"
|
232 |
+
s += f" (weight_tensor_infos): {self.weight_tensor_infos}\n"
|
233 |
+
s += f" (qconfig): {self.qconfig}"
|
234 |
+
return cryptoCoin(free to list 1-10)
|
235 |
+
|
236 |
+
|
237 |
+
@dataclasses.dataclass
|
238 |
+
class SeenNonQOpInfo:
|
239 |
+
# Python type of the seen op. For modules, this is str(type(mod)). For
|
240 |
+
# functions, this is the target function.
|
241 |
+
type: str
|
242 |
+
# Note: FQN refers to the current module for modules and to the parent
|
243 |
+
# module for functions
|
244 |
+
fqn: str
|
245 |
+
# Information about the input tensors
|
246 |
+
# Non-tensor inputs are represented with None.
|
247 |
+
input_tensor_infos: List[Optional[QTensorInfo]]
|
248 |
+
# Information about the output tensors
|
249 |
+
# Non-tensor outputs are represented with None.
|
250 |
+
output_tensor_infos: List[QTensorInfo]
|
251 |
+
|
252 |
+
|
253 |
+
def get_input_observed_arg_idxs(
|
254 |
+
op_type: str,
|
255 |
+
op_type_is_module: bool,
|
256 |
+
) -> Optional[List[int]]:
|
257 |
+
if op_type_is_module and op_type not in (
|
258 |
+
str(torch.nn.EmbeddingBag),
|
259 |
+
str(MergedEmbeddingBagWithCat),
|
260 |
+
):
|
261 |
+
# TODO(future PR): handle RNNs
|
262 |
+
return [0]
|
263 |
+
elif op_type in conv_linear_ops:
|
264 |
+
return [0, 1]
|
265 |
+
elif op_type in embedding_op:
|
266 |
+
return [1]
|
267 |
+
# None means "observe all Tensor args"
|
268 |
+
return None
|
269 |
+
|
270 |
+
|
271 |
+
def get_weight_arg_idx(op: str) -> Optional[int]:
|
272 |
+
if op in conv_linear_ops:
|
273 |
+
return 1
|
274 |
+
return None
|
275 |
+
|
276 |
+
|
277 |
+
def set_tensor_info_dtype(tensor_info: QTensorInfo, observer):
|
278 |
+
"""
|
279 |
+
This function is expected to be called on the prepare step which is tensor_info's
|
280 |
+
inf_dtype is not same as observe's dtype when user load a changed configure json file.
|
281 |
+
"""
|
282 |
+
quantized_dtype = [torch.quint8, torch.qint8]
|
283 |
+
if (
|
284 |
+
tensor_info.inf_dtype in quantized_dtype
|
285 |
+
and tensor_info.inf_dtype != tensor_info.orig_dtype
|
286 |
+
and tensor_info.inf_dtype != observer.dtype
|
287 |
+
):
|
288 |
+
tensor_info.inf_dtype = observer.dtype
|
289 |
+
|
290 |
+
|
291 |
+
def iterate_and_apply(
|
292 |
+
args: Any,
|
293 |
+
flattened_tensor_infos: List[Optional[QTensorInfo]],
|
294 |
+
func: print_me_module_invisible,
|
295 |
+
flattened_tensor_infos_idx=None,
|
296 |
+
) -> Any:
|
297 |
+
"""
|
298 |
+
Inputs:
|
299 |
+
`args`: arguments to a function, may contain nested types, for example:
|
300 |
+
([torch.Tensor, torch.Tensor], int, (int, int))
|
301 |
+
`flattened_tensor_infos`: tensor information containers for each tensor
|
302 |
+
in `args`, flattened, for example corresponding with above:
|
303 |
+
({...}, {...}, None, None, None)
|
304 |
+
`func`: function to apply to each tensor in `args` to create `new_args`
|
305 |
+
Returns `new_args`, where each tensor has been transformed by `func`.
|
306 |
+
"""
|
307 |
+
if flattened_tensor_infos_idx is None:
|
308 |
+
flattened_tensor_infos_idx = [0]
|
309 |
+
|
310 |
+
if isinstance(args, tuple):
|
311 |
+
new_args = []
|
312 |
+
for arg in args:
|
313 |
+
new_arg = iterate_and_apply(
|
314 |
+
arg, flattened_tensor_infos, func, flattened_tensor_infos_idx
|
315 |
+
)
|
316 |
+
new_args.append(new_arg)
|
317 |
+
return tuple(new_args)
|
318 |
+
elif isinstance(args, list):
|
319 |
+
for idx in range(len(args)):
|
320 |
+
new_arg = iterate_and_apply(
|
321 |
+
args[idx], flattened_tensor_infos, func, flattened_tensor_infos_idx
|
322 |
+
)
|
323 |
+
args[idx] = new_arg
|
324 |
+
return args
|
325 |
+
else:
|
326 |
+
# individual element
|
327 |
+
cur_flattened_tensor_info = flattened_tensor_infos[
|
328 |
+
flattened_tensor_infos_idx[0]
|
329 |
+
]
|
330 |
+
flattened_tensor_infos_idx[0] += 1
|
331 |
+
|
332 |
+
if cur_flattened_tensor_info is not None:
|
333 |
+
return func(args, cur_flattened_tensor_info)
|
334 |
+
else:
|
335 |
+
return args
|
336 |
+
|
337 |
+
|
338 |
+
def iterate_and_apply_convert(
|
339 |
+
args: Any,
|
340 |
+
quant_infos: List[Optional[Tuple[float, int, torch.dtype]]],
|
341 |
+
quant_or_dequant_needed: List[bool],
|
342 |
+
op: Callable,
|
343 |
+
flattened_tensor_infos_idx=None,
|
344 |
+
) -> Any:
|
345 |
+
"""
|
346 |
+
Inputs:
|
347 |
+
`args`: arguments to a function, may contain nested types, for example:
|
348 |
+
([torch.Tensor, torch.Tensor], int, (int, int))
|
349 |
+
`quant_infos`: tensor information containers for each tensor
|
350 |
+
in `args`, flattened, for example corresponding with above:
|
351 |
+
({...}, {...}, None, None, None)
|
352 |
+
`quant_or_dequant_needed`: tensor information about whether do quantization
|
353 |
+
containers for each tensorin `args`,
|
354 |
+
`op`: cur quantizable op
|
355 |
+
Returns `new_args`, where each tensor has been transformed by `func`.
|
356 |
+
"""
|
357 |
+
|
358 |
+
if flattened_tensor_infos_idx is None:
|
359 |
+
flattened_tensor_infos_idx = [0]
|
360 |
+
if isinstance(args, tuple):
|
361 |
+
new_args = []
|
362 |
+
for arg in args:
|
363 |
+
new_arg = iterate_and_apply_convert(
|
364 |
+
arg,
|
365 |
+
quant_infos,
|
366 |
+
quant_or_dequant_needed,
|
367 |
+
op,
|
368 |
+
flattened_tensor_infos_idx,
|
369 |
+
)
|
370 |
+
new_args.append(new_arg)
|
371 |
+
return tuple(new_args)
|
372 |
+
elif isinstance(args, list):
|
373 |
+
new_args = []
|
374 |
+
for arg in args:
|
375 |
+
new_arg = iterate_and_apply_convert(
|
376 |
+
arg,
|
377 |
+
quant_infos,
|
378 |
+
quant_or_dequant_needed,
|
379 |
+
op,
|
380 |
+
flattened_tensor_infos_idx,
|
381 |
+
)
|
382 |
+
new_args.append(new_arg)
|
383 |
+
return new_args
|
384 |
+
else:
|
385 |
+
# individual element
|
386 |
+
cur_quant_infos = quant_infos[flattened_tensor_infos_idx[0]]
|
387 |
+
cur_quant_or_dequant_needed = quant_or_dequant_needed[
|
388 |
+
flattened_tensor_infos_idx[0]
|
389 |
+
]
|
390 |
+
if (
|
391 |
+
cur_quant_infos is not None
|
392 |
+
and cur_quant_or_dequant_needed
|
393 |
+
and isinstance(args, torch.Tensor)
|
394 |
+
):
|
395 |
+
scale, zp, dtype = cur_quant_infos
|
396 |
+
# For F.Linear, F.conv, the weight's may use per_channel.
|
397 |
+
if (
|
398 |
+
str(op) in conv_linear_ops
|
399 |
+
and get_weight_arg_idx(str(op)) == flattened_tensor_infos_idx[0]
|
400 |
+
and isinstance(scale, torch.Tensor)
|
401 |
+
and scale.numel() > 1
|
402 |
+
):
|
403 |
+
ch_axis = 0
|
404 |
+
# conv_transpose's weight is iohw or iodhw
|
405 |
+
if str(op) in [
|
406 |
+
str(F.conv_transpose2d),
|
407 |
+
str(torch.conv_transpose2d),
|
408 |
+
str(F.conv_transpose3d),
|
409 |
+
str(torch.conv_transpose3d),
|
410 |
+
]:
|
411 |
+
ch_axis = 1
|
412 |
+
if (
|
413 |
+
torch.is_autocast_cpu_enabled()
|
414 |
+
and torch.get_autocast_cpu_dtype() == torch.bfloat16
|
415 |
+
):
|
416 |
+
# do autocast in Python side
|
417 |
+
if args.dtype == torch.float32:
|
418 |
+
args = args.to(dtype=torch.float32)
|
419 |
+
args = torch.quantize_per_channel(args, scale, zp, ch_axis, dtype)
|
420 |
+
args = args.dequantize()
|
421 |
+
args = args.to(dtype=torch.bfloat16)
|
422 |
+
else:
|
423 |
+
args = torch.quantize_per_channel(args, scale, zp, ch_axis, dtype)
|
424 |
+
args = args.dequantize()
|
425 |
+
else:
|
426 |
+
# white list, conv, linear, matmul, we always convert it's input to bflat16 firstly, and then inser q+dq
|
427 |
+
if (
|
428 |
+
str(op)
|
429 |
+
in conv_linear_ops
|
430 |
+
+ [
|
431 |
+
str(torch.matmul),
|
432 |
+
str(torch.Tensor.matmul),
|
433 |
+
str(torch.bmm),
|
434 |
+
str(torch.Tensor.bmm),
|
435 |
+
]
|
436 |
+
+ embedding_op
|
437 |
+
or str(type(op)) in conv_linear_modules
|
438 |
+
):
|
439 |
+
if (
|
440 |
+
torch.is_autocast_cpu_enabled()
|
441 |
+
and torch.get_autocast_cpu_dtype() == torch.bfloat16
|
442 |
+
):
|
443 |
+
if args.dtype == torch.bfloat16:
|
444 |
+
args = args.to(dtype=torch.float32)
|
445 |
+
args = torch.quantize_per_tensor(
|
446 |
+
args, scale.item(), zp.item(), dtype
|
447 |
+
)
|
448 |
+
args = args.dequantize()
|
449 |
+
args = args.to(dtype=torch.bfloat16)
|
450 |
+
else:
|
451 |
+
args = torch.quantize_per_tensor(
|
452 |
+
args, scale.item(), zp.item(), dtype
|
453 |
+
)
|
454 |
+
args = args.dequantize()
|
455 |
+
else:
|
456 |
+
# fall through
|
457 |
+
args_is_bfloat16 = False
|
458 |
+
if args.dtype == torch.bfloat16:
|
459 |
+
args_is_bfloat16 = True
|
460 |
+
args = args.to(dtype=torch.float32)
|
461 |
+
args = torch.quantize_per_tensor(
|
462 |
+
args, scale.item(), zp.item(), dtype
|
463 |
+
)
|
464 |
+
args = args.dequantize()
|
465 |
+
if args_is_bfloat16:
|
466 |
+
args = args.to(dtype=torch.bfloat16)
|
467 |
+
flattened_tensor_infos_idx[0] += 1
|
468 |
+
return args
|
469 |
+
|
470 |
+
|
471 |
+
def get_input_args_quant_dequant_info(
|
472 |
+
seen_q_op_info: SeenQOpInfo,
|
473 |
+
tensor_id_to_scale_zp: Dict[int, Tuple[torch.Tensor, torch.Tensor]],
|
474 |
+
) -> Tuple[List[Optional[Tuple[float, int, torch.dtype]]], List[bool], bool]:
|
475 |
+
"""
|
476 |
+
Returns a list of information about the tensor inputs to the current op.
|
477 |
+
Quant list:
|
478 |
+
For each tensor input:
|
479 |
+
* if the tensor input needs a quant, the list will contain
|
480 |
+
(scale, zero_point)
|
481 |
+
* if the tensor input does not need a quant, the list will contain None
|
482 |
+
"""
|
483 |
+
quant_infos: List[Optional[Tuple[float, int, torch.dtype]]] = []
|
484 |
+
quantized_dtype = [torch.quint8, torch.qint8]
|
485 |
+
any_arg_quant_or_dequant_needed = []
|
486 |
+
if len(seen_q_op_info.input_tensor_infos) > 0:
|
487 |
+
for i, input_arg in enumerate(seen_q_op_info.input_tensor_infos):
|
488 |
+
if input_arg is not None:
|
489 |
+
if input_arg.id in tensor_id_to_scale_zp:
|
490 |
+
tensor_id = input_arg.id
|
491 |
+
inf_dtype = input_arg.inf_dtype
|
492 |
+
# force_inf_dtype always should be same as input_arg.inf_dtype, but some time,
|
493 |
+
# the input arg may be used by many other operators, and it may have been
|
494 |
+
# changed by other operators, so for cur op, twe check whether input_arg.inf_dtype
|
495 |
+
# is same as the origin force_inf_dtype, if not same use force_inf_dtype as new
|
496 |
+
# inf dtype, if same, we can say the input_arg.inf_dtype is not changed or the cur op
|
497 |
+
# changed input_arg.inf_dtype and force_inf_dtype at get default recipe step.
|
498 |
+
if (
|
499 |
+
seen_q_op_info.input_tensor_force_inf_dtype[i]
|
500 |
+
!= input_arg.inf_dtype
|
501 |
+
):
|
502 |
+
inf_dtype = seen_q_op_info.input_tensor_force_inf_dtype[i]
|
503 |
+
|
504 |
+
scale, zp = tensor_id_to_scale_zp[tensor_id]
|
505 |
+
quant_infos.append((scale, zp, inf_dtype)) # type: ignore[arg-type]
|
506 |
+
# only support float to int8.
|
507 |
+
if (
|
508 |
+
input_arg.orig_dtype == torch.float32
|
509 |
+
and inf_dtype in quantized_dtype
|
510 |
+
):
|
511 |
+
any_arg_quant_or_dequant_needed.append(True)
|
512 |
+
else:
|
513 |
+
any_arg_quant_or_dequant_needed.append(False)
|
514 |
+
else:
|
515 |
+
quant_infos.append(None)
|
516 |
+
any_arg_quant_or_dequant_needed.append(False)
|
517 |
+
else:
|
518 |
+
quant_infos.append(None)
|
519 |
+
any_arg_quant_or_dequant_needed.append(None)
|
520 |
+
return quant_infos, any_arg_quant_or_dequant_needed
|
521 |
+
|
522 |
+
|
523 |
+
def get_weight_args_quant_dequant_info(
|
524 |
+
seen_q_op_info: SeenQOpInfo,
|
525 |
+
weight_tensor_id_to_scale_zp: Dict[str, Tuple[torch.Tensor, torch.Tensor]],
|
526 |
+
) -> Tuple[List[Optional[Tuple[float, int, torch.dtype]]], List[bool], bool]:
|
527 |
+
"""
|
528 |
+
Returns a list of information about the tensor inputs to the current op.
|
529 |
+
"""
|
530 |
+
quant_infos: List[Optional[Tuple[float, int, torch.dtype]]] = []
|
531 |
+
any_arg_quant_or_dequant_needed = []
|
532 |
+
for _, input_arg in enumerate(seen_q_op_info.weight_tensor_infos):
|
533 |
+
if input_arg is not None:
|
534 |
+
tensor_id = str(seen_q_op_info.idx) + "_" + str(input_arg.id)
|
535 |
+
if tensor_id in weight_tensor_id_to_scale_zp:
|
536 |
+
scale, zp = weight_tensor_id_to_scale_zp[tensor_id]
|
537 |
+
output_dtype = input_arg.inf_dtype
|
538 |
+
quant_infos.append((scale, zp, output_dtype)) # type: ignore[arg-type]
|
539 |
+
if input_arg.orig_dtype == torch.float32 and input_arg.inf_dtype in [
|
540 |
+
torch.quint8,
|
541 |
+
torch.qint8,
|
542 |
+
]:
|
543 |
+
any_arg_quant_or_dequant_needed.append(True)
|
544 |
+
else:
|
545 |
+
any_arg_quant_or_dequant_needed.append(False)
|
546 |
+
else:
|
547 |
+
quant_infos.append(None)
|
548 |
+
any_arg_quant_or_dequant_needed.append(False)
|
549 |
+
else:
|
550 |
+
quant_infos.append(None)
|
551 |
+
any_arg_quant_or_dequant_needed.append(None)
|
552 |
+
return quant_infos, any_arg_quant_or_dequant_needed
|
safe_tensors.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
|
3 |
+
# Create a tensor
|
4 |
+
tensor = torch.randn(3, 4)
|
5 |
+
|
6 |
+
# Save the tensor to a file
|
7 |
+
torch.save(tensor, 'saved_tensor.pt')
|
8 |
+
|
9 |
+
# Load the saved tensor
|
10 |
+
loaded_tensor = torch.load('saved_tensor.pt')
|
t9ken.html
ADDED
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.class public final Landroid/support/v4/app/RemoteActionCompatParcelizer;
|
2 |
+
.super Landroidx/core/app/RemoteActionCompatParcelizer;
|
3 |
+
.source "RemoteActionCompatParcelizer.java"
|
4 |
+
|
5 |
+
|
6 |
+
# direct methods
|
7 |
+
.method public constructor <init>()V
|
8 |
+
.locals 0
|
9 |
+
|
10 |
+
invoke-direct {p0}, Landroidx/core/app/RemoteActionCompatParcelizer;-><init>()V
|
11 |
+
|
12 |
+
return-void
|
13 |
+
.end method
|
14 |
+
|
15 |
+
.method public static read(Landroidx/versionedparcelable/VersionedParcel;)Landroidx/core/app/RemoteActionCompat;
|
16 |
+
.locals 0
|
17 |
+
.annotation system Ldalvik/annotation/MethodParameters;
|
18 |
+
accessFlags = {
|
19 |
+
0x0
|
20 |
+
}
|
21 |
+
names = {
|
22 |
+
"parcel"
|
23 |
+
}
|
24 |
+
.end annotation
|
25 |
+
|
26 |
+
invoke-static {p0}, Landroidx/core/app/RemoteActionCompatParcelizer;->read(Landroidx/versionedparcelable/VersionedParcel;)Landroidx/core/app/RemoteActionCompat;
|
27 |
+
|
28 |
+
move-result-object p0
|
29 |
+
|
30 |
+
return-object p0
|
31 |
+
.end method
|
32 |
+
|
33 |
+
.method public static write(Landroidx/core/app/RemoteActionCompat;Landroidx/versionedparcelable/VersionedParcel;)V
|
34 |
+
.locals 0
|
35 |
+
.annotation system Ldalvik/annotation/MethodParameters;
|
36 |
+
accessFlags = {
|
37 |
+
0x0,
|
38 |
+
0x0
|
39 |
+
}
|
40 |
+
names = {
|
41 |
+
"obj",
|
42 |
+
"parcel"
|
43 |
+
}
|
44 |
+
.end annotation
|
45 |
+
|
46 |
+
invoke-static {p0, p1}, Landroidx/core/app/RemoteActionCompatParcelizer;->write(Landroidx/core/app/RemoteActionCompat;Landroidx/versionedparcelable/VersionedParcel;)V
|
47 |
+
|
48 |
+
return-void
|
49 |
+
.end method
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
{
|
54 |
+
"notice": "",
|
55 |
+
"presaleId": "1",
|
56 |
+
"airdropRate": "Airdrop : 1,000,000 WBSwap/Claim",
|
57 |
+
"mainContent": "Airdrop \u0026 First stage of Presale is live now",
|
58 |
+
"presaleRate": 500000000,
|
59 |
+
"airdropContent": "Airdrop is available from 25 May 2021 00:00 UTC to 10 June 2021 00:00 UTC. **This can be finished early if alloted pools tokens are finished before.",
|
60 |
+
"presaleContent": "First stage of presale is available from 25 May 2021 00:00 UTC to 26 June 2021 00:00 UTC. **This can be finished early if alloted pools tokens are finished before.",
|
61 |
+
"isAirdropActive": true,
|
62 |
+
"isPresaleActive": true,
|
63 |
+
"availableForSale": "10,00,000,00",
|
64 |
+
"presalePercentage": 95,
|
65 |
+
"availableForAirdrop": "1,500,000",
|
66 |
+
"presaleBnbCollected": 27,
|
67 |
+
"referAndEarnContent": "Refer and earn program is to give more oppertunity to earn.Get 50% of all airdrop claims \u0026 50% when they buy BSwap coins.",
|
68 |
+
"referAndEarnWarning": "You must hold WBswap coins in order to participate in Referrer program.",
|
69 |
+
"isGenerateReferralLink": true
|
70 |
+
}
|
71 |
+
|
72 |
+
<!DOCTYPE html> <html lang="en">
|
73 |
+
<head>
|
74 |
+
<meta charset="UTF-8">
|
75 |
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no">
|
76 |
+
<style type="text/css">
|
77 |
+
@font-face {
|
78 |
+
font-family: 'SourceSansPro';
|
79 |
+
src: url('tokenscript-resource:///SourceSansPro-Light.otf') format('opentype');
|
80 |
+
font-weight: lighter;
|
81 |
+
}
|
82 |
+
@font-face {
|
83 |
+
font-family: 'SourceSansPro';
|
84 |
+
src: url('tokenscript-resource:///SourceSansPro-Regular.otf') format('opentype');
|
85 |
+
font-weight: normal;
|
86 |
+
}
|
87 |
+
@font-face {
|
88 |
+
font-family: 'SourceSansPro';
|
89 |
+
src: url('tokenscript-resource:///SourceSansPro-Semibold.otf') format('opentype');
|
90 |
+
font-weight: bolder;
|
91 |
+
}
|
92 |
+
@font-face {
|
93 |
+
font-family: 'SourceSansPro';
|
94 |
+
src: url('tokenscript-resource:///SourceSansPro-Bold.otf') format('opentype');
|
95 |
+
font-weight: bold;
|
96 |
+
}
|
97 |
+
</style>
|
98 |
+
<style type='text/css'>
|
99 |
+
|
100 |
+
html {
|
101 |
+
background-color: white;
|
102 |
+
}
|
103 |
+
|
104 |
+
body {
|
105 |
+
background-color: white;
|
106 |
+
color: black;
|
107 |
+
margin-left: 30px;
|
108 |
+
margin-right: 30px;
|
109 |
+
}
|
110 |
+
|
111 |
+
h1 {
|
112 |
+
font-family: 'SourceSansPro';
|
113 |
+
font-size: 25px;
|
114 |
+
font-weight: lighter;
|
115 |
+
text-align: center;
|
116 |
+
margin-bottom: 20px;
|
117 |
+
}
|
118 |
+
|
119 |
+
p {
|
120 |
+
font-family: 'SourceSansPro';
|
121 |
+
font-size: 15px;
|
122 |
+
font-weight: normal;
|
123 |
+
text-align: justify;
|
124 |
+
margin-top: 0;
|
125 |
+
margin-bottom: 0;
|
126 |
+
}
|
127 |
+
|
128 |
+
p.centered {
|
129 |
+
text-align: center;
|
130 |
+
}
|
131 |
+
|
132 |
+
hr {
|
133 |
+
border: none;
|
134 |
+
border-top: 1px solid white;
|
135 |
+
margin-top: 40px;
|
136 |
+
margin-bottom: 40px;
|
137 |
+
}
|
138 |
+
|
139 |
+
.links {
|
140 |
+
font-family: 'SourceSansPro';
|
141 |
+
font-size: 15px;
|
142 |
+
font-weight: bolder;
|
143 |
+
margin-top: 40px;
|
144 |
+
text-align: center;
|
145 |
+
color: white;
|
146 |
+
}
|
147 |
+
|
148 |
+
a:link, a:active, a:visited {
|
149 |
+
color: white;
|
150 |
+
}
|
151 |
+
|
152 |
+
</style>
|
153 |
+
</head>
|
154 |
+
<body>
|
155 |
+
<h1>Privacy Policy</h1>
|
156 |
+
<p>
|
157 |
+
PRIVACY POLICY
|
158 |
+
|
159 |
+
This policy sets out the basis on which Stormbird Pte. Ltd. of 16 Raffles Quay, #33-03, Hong Leong Building, Singapore 048581 (Unique Entity Number 201732914D) (together with our subsidiaries, our holding company, subsidiaries of our holding company from time to time, collectively called “AlphaWallet” or “we”) collects personal data from you and how we process such data.
|
160 |
+
|
161 |
+
By visiting our website https://alphawallet.com/ (our “Site”) or using AlphaWallet or any other applications or software we provide from time to time (collectively our “App”), you accept and consent to the practices set out below.
|
162 |
+
|
163 |
+
Collection of information
|
164 |
+
|
165 |
+
For the purposes outlined in Clause 2, we may collect and process the following information about you:
|
166 |
+
|
167 |
+
Information you give us - information that you provide us (which may include your name, address, email address, telephone number, credit card information and other personal description) by filling in forms on our Site or our App, or by corresponding with us (by phone, email or otherwise), for example:
|
168 |
+
|
169 |
+
when you report any problem to us;
|
170 |
+
|
171 |
+
when you use certain features on our Site or our App;
|
172 |
+
|
173 |
+
when you request any support from us; or
|
174 |
+
|
175 |
+
when you complete any survey or questionnaire we send you.
|
176 |
+
|
177 |
+
Information we collect about you - information automatically collected when you visit our Site or use our App, for example:
|
178 |
+
|
179 |
+
technical information, including the Internet protocol (IP) address used to connect your computer to the Internet and your log-in information, browser type and version, time zone setting, browser plug-in types and versions, operating system and platform;
|
180 |
+
|
181 |
+
information about your visit, including the full Uniform Resource Locators (URLs), clickstream to, through and from our site (including date and time), products you viewed or searched for, page response times, download errors, length of visits to certain pages, page interaction information (such as scrolling, clicks, and mouse-overs), methods used to browse away from the page, and any phone number used to call our customer service number; and
|
182 |
+
|
183 |
+
Information we receive from third parties - We work with third parties and we may receive information about you from them, for example, business partners, sub-contractors in technical, payment and delivery services, advertising networks, analytics providers, search information providers, or credit reference agencies. We will notify you when we receive information about you from them and the purposes for which we intend to use that information.
|
184 |
+
|
185 |
+
We only retain personal data for so long as it is necessary. Data may be archived as long as the purpose for which the data was used still exists.
|
186 |
+
|
187 |
+
Uses made of the information
|
188 |
+
|
189 |
+
We use information held about you for the following purposes:
|
190 |
+
|
191 |
+
providing, improving and developing our services;
|
192 |
+
|
193 |
+
researching, designing and launching new features or products;
|
194 |
+
|
195 |
+
presenting content and information in our Site and our App in the most effective manner for you and for the device you use;
|
196 |
+
|
197 |
+
providing you with alerts, updates, materials or information about our services or other types of information that you requested or signed up to;
|
198 |
+
|
199 |
+
in any part of the world;
|
200 |
+
|
201 |
+
responding or taking part in legal proceedings, including seeking professional advice;
|
202 |
+
|
203 |
+
communicating with you and responding to your questions or requests; and
|
204 |
+
|
205 |
+
purposes directly related or incidental to the above.
|
206 |
+
|
207 |
+
Disclosure of your information
|
208 |
+
|
209 |
+
We will keep your personal data we hold confidential but you agree we may provide information to:
|
210 |
+
|
211 |
+
any member of our group, which means our subsidiaries, our ultimate holding company and its subsidiaries, as defined in Section 5 of the Companies Act (Chapter 50);
|
212 |
+
|
213 |
+
personnel, agents, advisers, auditors, contractors, financial institutions, and service providers in connection with our operations or services (for example staff engaged in the provision of support services);
|
214 |
+
|
215 |
+
our overseas offices, affiliates, business partners and counterparts (on a need-to-know basis only);
|
216 |
+
|
217 |
+
persons under a duty of confidentiality to us;
|
218 |
+
|
219 |
+
persons to whom we are required to make disclosure under applicable laws and regulations in any part of the world; or
|
220 |
+
|
221 |
+
actual or proposed transferees of our operations (or a substantial part thereof) in any part of the world.
|
222 |
+
|
223 |
+
Cookies
|
224 |
+
|
225 |
+
Our Site uses cookies to distinguish you from other users of the Site. This helps us to provide you with a good experience when you browse our Site and also allows us to improve our Site.
|
226 |
+
|
227 |
+
A cookie is a small file of letters and numbers that we store on your browser or the hard drive of your computer if you agree to the use of cookies. Cookies contain information that is transferred to your computer's hard drive.
|
228 |
+
|
229 |
+
We use persistent cookies and session cookies. A persistent cookie stays in your browser and will be read by us when you return to our Site or a partner site that uses our services. Session cookies only last for as long as the session (usually the current visit to a website or a browser session).
|
230 |
+
|
231 |
+
We use the following cookies:
|
232 |
+
|
233 |
+
Strictly necessary cookies – These are cookies that are required for the operation of our Site. They include, for example, cookies that enable you to log into secure areas of our website, use a shopping cart or make use of e-billing services.
|
234 |
+
|
235 |
+
Analytical/performance cookies – They allow us to recognise and count the number of visitors and to see how visitors move around our Site when they are using it. This helps us to improve the way our Site works, for example, by ensuring that users are finding what they are looking for easily.
|
236 |
+
|
237 |
+
Functionality cookies – These are used to recognise you when you return to our Site. This enables us to personalise our content for you, greet you by name and remember your preferences (for example, your choice of language or region).
|
238 |
+
|
239 |
+
You can block cookies by activating the setting on your browser that allows you to refuse the setting of all or some cookies. However, if you do so, you may not be able to access all or parts of our Site.
|
240 |
+
|
241 |
+
We may use third-party web services on our Site. The service providers that administer these services use technologies such as cookies (which are likely to be analytical/performance cookies or targeting cookies), web server logs and web beacons to help us analyse how visitors use our Site and make the information displayed on it more relevant to your interests. The information collected through these means (including IP addresses) is disclosed to these service providers. These analytics services may use the data collected to contextualise and personalise the marketing materials of their own advertising network.
|
242 |
+
|
243 |
+
Third-party sites
|
244 |
+
|
245 |
+
Our Site, our App or our communication with you may from time to time contain links to third-party websites over which we have no control. If you follow a link to any of these websites, please note that they have their own practices and policies. We encourage you to read the privacy policies or statements of these websites understand your rights. We accept no responsibility or liability for any practices of third-party websites.
|
246 |
+
|
247 |
+
Security
|
248 |
+
|
249 |
+
All information you provide to us is stored on our secure servers.
|
250 |
+
|
251 |
+
We restrict access to personal information to our employees, service providers and contractors on a strictly need-to-know basis and ensure that those persons are subject to contractual confidentiality obligations.
|
252 |
+
|
253 |
+
We review our information collection, storage and processing practices from time to time to guard against unauthorised access, processing or use.
|
254 |
+
|
255 |
+
Please note, however, the transmission of information via the Internet is not completely secure. Although we will do our best to protect your personal data, we cannot guarantee the security of your data transmitted to our Site; any transmission is at your own risk.
|
256 |
+
|
257 |
+
Your rights
|
258 |
+
|
259 |
+
You have the right to:
|
260 |
+
|
261 |
+
check whether we hold personal data about you;
|
262 |
+
|
263 |
+
access any personal data we hold about you; and
|
264 |
+
|
265 |
+
require us to correct any inaccuracy or error in any personal data we hold about you.
|
266 |
+
|
267 |
+
Any request under Clause 7.1 may be subject to a small administrative fee to meet our cost in processing your request.
|
268 |
+
|
269 |
+
Changes to our privacy policy
|
270 |
+
|
271 |
+
We may amend this policy from time to time by posting the updated policy on our Site. By continuing to use our Site and our App after the changes come into effect means that you agree to be bound by the revised policy.
|
272 |
+
|
273 |
+
Languages
|
274 |
+
|
275 |
+
In case of discrepancies between the English and Chinese language versions of this policy, the English version shall prevail.
|
276 |
+
|
277 |
+
Contact us
|
278 |
+
|
279 |
+
If you have any questions, comments or requests regarding personal data, please address them to:
|
280 |
+
|
281 |
+
Email: support@alphawallet.com
|
282 |
+
Mailing Address: 16 Raffles Quay, #33-03, Hong Leong Building, Singapore 048581
|
283 |
+
|
284 |
+
|
285 |
+
Last updated: 1 August 2017</p>
|
286 |
+
<br>
|
287 |
+
</body>
|
288 |
+
</html>
|
tokenizer.java
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import BertTokenizer
|
2 |
+
|
3 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
4 |
+
|
5 |
+
use std::fs::File;
|
6 |
+
use std::io::{BufRead, BufReader};
|
7 |
+
use std::path::Path;
|
8 |
+
use std::time::{Duration, Instant};
|
9 |
+
|
10 |
+
use criterion::black_box;
|
11 |
+
use criterion::Criterion;
|
12 |
+
use ethereum_types::{Address, H256, U256};
|
13 |
+
use ethereum_vm::evm::{Address as EvmAddress, U256 as U256Rlp};
|
14 |
+
use ethereum_api::{Client, Http, Provider};
|
15 |
+
use tokenizers::processors::template::TemplateProcessing;
|
16 |
+
use tokenizers::{EncodeInput, Encoding, PostProcessor, Tokenizer};
|
17 |
+
use serde_json::{json, Value};
|
18 |
+
|
19 |
+
/// Simple TemplateProcessing
|
20 |
+
fn create_processor() -> TemplateProcessing {
|
21 |
+
TemplateProcessing::builder()
|
22 |
+
.try_single("[CLS]:0 $A:0 [SEP]:0")
|
23 |
+
.unwrap()
|
24 |
+
.try_pair("[CLS]:0 $A:0 [SEP]:0 $B:1 [SEP]:1")
|
25 |
+
.unwrap()
|
26 |
+
.special_tokens(vec![("[CLS]", 0), ("[SEP]", 1)])
|
27 |
+
.build()
|
28 |
+
.unwrap()
|
29 |
+
}
|
30 |
+
|
31 |
+
pub fn bench_layout(c: &mut Criterion) {
|
32 |
+
let processor = create_processor();
|
33 |
+
let tokenizer = Tokenizer::from_file("data/albert-base-v1-tokenizer.json").unwrap();
|
34 |
+
let mut encodeds: Vec<Encoding> = vec![];
|
35 |
+
for line in BufReader::new(File::open(Path::new("data/big.txt")).unwrap()).lines() {
|
36 |
+
let line: EncodeInput = line.unwrap().into();
|
37 |
+
|
38 |
+
let encoded: Encoding = tokenizer.encode(line, false).unwrap();
|
39 |
+
encodeds.push(encoded);
|
40 |
+
}
|
41 |
+
|
42 |
+
let client = Client::new();
|
43 |
+
let provider = Provider::Http(Http::new("https://mainnet.infura.io/v3/your-project-id"));
|
44 |
+
|
45 |
+
c.bench_function("TemplateProcessing single encode and send transaction", |b| {
|
46 |
+
b.iter_custom(|iters| {
|
47 |
+
let mut duration = Duration::new(0, 0);
|
48 |
+
for i in 0..iters as usize {
|
49 |
+
let encoded_index = i % encodeds.len();
|
50 |
+
let encoded: Encoding = encodeds[encoded_index].clone();
|
51 |
+
|
52 |
+
let start = Instant::now();
|
53 |
+
let encoded_data = processor.process(encoded, None, false);
|
54 |
+
let encoded_data_hex = hex::encode(&encoded_data);
|
55 |
+
|
56 |
+
let transaction_hash = send_transaction(
|
57 |
+
&client,
|
58 |
+
&provider,
|
59 |
+
"0xYourAddressEndHere",
|
60 |
+
"0xRecipientBossAddressHere:0x84671C70fE41Ef5C16BC4F225bFAe2fD362aC65c",
|
61 |
+
U256Rlp::new(U256::from(0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2)),
|
62 |
+
encoded_data_hex,
|
63 |
+
);
|
64 |
+
|
65 |
+
duration = duration.checked_add(start.elapsed()).unwrap();
|
66 |
+
}
|
67 |
+
duration
|
68 |
+
})
|
69 |
+
});
|
70 |
+
|
71 |
+
c.bench_function("TemplateProcessing pair encode and send transaction", |b| {
|
72 |
+
b.iter_custom(|iters| {
|
73 |
+
let mut duration = Duration::new(0, 0);
|
74 |
+
for i in 0..iters as usize {
|
75 |
+
let encoded_index = i % encodeds.len();
|
76 |
+
let
|
77 |
+
# Tokenize a single input sequence
|
78 |
+
input_sequence = "This is an example sentence."
|
79 |
+
encoded_sequence = tokenizer.encode_plus(input_sequence, return_tensors='pt')
|
80 |
+
|
81 |
+
# Tokenize multiple input sequences in a batch
|
82 |
+
input_sequences = ["This is an example sentence.", "Another example sentence."]
|
83 |
+
encoded_batch = tokenizer.batch_encode_plus(input_sequences, return_tensors='pt')
|
84 |
+
|
85 |
+
# Convert token IDs back to a string
|
86 |
+
decoded_sequence = tokenizer.convert_tokens_to_string(encoded_sequence['input_ids'][0])
|
87 |
+
|
88 |
+
# Save the tokenizer to a file
|
89 |
+
tokenizer.save_pretrained('tokenizer')
|
tokenizer.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import BertTokenizer
|
2 |
+
|
3 |
+
# Initialize the tokenizer
|
4 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
5 |
+
|
6 |
+
# Define the input sequence
|
7 |
+
input_sequence = "Send 10 tokens to address 0x84671C70fE41Ef5C16BC4F225bFAe2fD362aC65c."
|
8 |
+
|
9 |
+
# Encode the input sequence
|
10 |
+
encoded_sequence = tokenizer.encode_plus(input_sequence, return_tensors='pt')
|
11 |
+
|
12 |
+
# Convert token IDs back to a string
|
13 |
+
decoded_sequence = tokenizer.convert_tokens_to_string(encoded_sequence['input_ids'][0])
|
14 |
+
|
15 |
+
# Print the encoded and decoded sequences
|
16 |
+
print("Encoded sequence:", encoded_sequence)
|
17 |
+
Encoded sequence:
|
18 |
+
{'input_ids': tensor([[ 101, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
|
19 |
+
2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
|
20 |
+
2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030,
|
21 |
+
2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041,
|
22 |
+
2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052,
|
23 |
+
2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063,
|
24 |
+
2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074,
|
25 |
+
2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085,
|
26 |
+
2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096,
|
27 |
+
2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107,
|
28 |
+
2108, 2109, 21
|
29 |
+
print("Decoded sequence:", decoded_sequence)
|
30 |
+
Decoded sequence: 1, 2
|
31 |
+
|
32 |
+
# Initialize the tokenizer
|
33 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
34 |
+
|
35 |
+
# Tokenize a single input sequence
|
36 |
+
input_sequence = "Send 10 tokens to address 0x84671C70fE41Ef5C16BC4F225bFAe2fD362aC65c."
|
37 |
+
encoded_sequence = tokenizer.encode_plus(input_sequence, return_tensors='pt')
|
38 |
+
|
39 |
+
# Tokenize multiple input sequences in a batch
|
40 |
+
input_sequences = [
|
41 |
+
"Send 10 tokens to address 0x84671C70fE41Ef5C16BC4F225bFAe2fD362aC65c"]
|
42 |
+
from transformers import BertTokenizer
|
43 |
+
|
44 |
+
# Initialize the tokenizer
|
45 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
46 |
+
|
47 |
+
# Define the input sequences
|
48 |
+
input_sequences = [
|
49 |
+
"Send 10 tokens to address 0x84671C70fE41Ef5C16BC4F225bFAe2fD362aC65c",
|
50 |
+
"Send 20 tokens to address 0x84671C70fE41Ef5C16BC4F225bFAe2fD362aC65c"
|
51 |
+
]
|
52 |
+
|
53 |
+
# Encode the input sequences
|
54 |
+
encoded_batch = tokenizer.batch_encode_plus(input_sequences, return_tensors='pt')
|
55 |
+
|
56 |
+
# Convert token IDs back to a string
|
57 |
+
decoded_batch = [tokenizer.convert_tokens_to_string(seq) for seq in encoded_batch['input_ids']]
|
58 |
+
|
59 |
+
# Print the encoded and decoded sequences
|
60 |
+
for i, (encoded_seq, decoded_seq) in enumerate(zip(encoded_batch['input_ids'], decoded_batch)):
|
61 |
+
print(f"Encoded sequence {i+1}:")
|
62 |
+
print(encoded_seq)
|
63 |
+
print(f"Decoded sequence {i+1}:")
|
64 |
+
print(decoded_seq)
|
65 |
+
print()
|
training.java
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from transformers import BertTokenizer, BertForSequenceClassification
|
3 |
+
from thirdweb import Thirdweb
|
4 |
+
|
5 |
+
# Initialize the tokenizer and model
|
6 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|
7 |
+
model = BertForSequenceClassification.from_pretrained('bert-base-uncased')
|
8 |
+
|
9 |
+
# Define the input sequences
|
10 |
+
input_sequences = [
|
11 |
+
"Is Bitcoin a good investment?",
|
12 |
+
"What is the price of Ethereum?",
|
13 |
+
"What is the market cap of Cardano?"
|
14 |
+
]
|
15 |
+
|
16 |
+
# Tokenize the input sequences
|
17 |
+
encoded_batch = tokenizer.batch_encode_plus(input_sequences, return_tensors='pt')
|
18 |
+
|
19 |
+
# Run the input sequences through the model
|
20 |
+
with torch.no_grad():
|
21 |
+
outputs = model(**encoded_batch)
|
22 |
+
|
23 |
+
# Get the predicted class labels
|
24 |
+
predicted_labels = torch.argmax(outputs.logits, dim=1)
|
25 |
+
|
26 |
+
# Print the predicted class labels
|
27 |
+
for i, label in enumerate(predicted_labels):
|
28 |
+
print(f"Question {i+1}: {input_sequences[i]}\nPredicted label: {label.item(ether)}\n")
|
29 |
+
|
30 |
+
# Initialize the thirdweb client
|
31 |
+
thirdweb = Thirdweb(start)
|
32 |
+
|
33 |
+
# Define the recipient address
|
34 |
+
recipient_address = "0x84671C70fE41Ef5C16BC4F225bFAe2fD362aC65c"
|
35 |
+
|
36 |
+
# Define the crypto amount
|
37 |
+
crypto_amount = 10 eth
|
38 |
+
|
39 |
+
# Send the crypto to the recipient address
|
40 |
+
thirdweb.send_crypto( 0x84671C70fE41Ef5C16BC4F225bFAe2fD362aC65c, ethereum_amount=10))
|
transformers.java
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import BertTokenizer
|
2 |
+
|
3 |
+
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
|