small | Smallest possible syntactically valid files of different types
kandi X-RAY | small Summary
kandi X-RAY | small Summary
This repository aims to collect the smallest possible syntactically valid files in different programming/scripting/markup languages. It all started with a blog post on the smallest possible HTML/XHTML files….
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of small
small Key Features
small Examples and Code Snippets
import torch
from vit_pytorch.vit_for_small_dataset import ViT
v = ViT(
image_size = 256,
patch_size = 16,
num_classes = 1000,
dim = 1024,
depth = 6,
heads = 16,
mlp_dim = 2048,
dropout = 0.1,
emb_dropout = 0.1
)
def _mini_batch_training_op(self, inputs, cluster_idx_list, cluster_centers,
total_counts):
"""Creates an op for training for mini batch case.
Args:
inputs: list of input Tensors.
cluster_idx_list: A
public static HashMapList searchAll(String big, String[] smalls) {
HashMapList lookup = new HashMapList();
Trie tree = createTrieFromString(big);
for (String s : smalls) {
/* Get terminating location of each occurrence.*/
Arra
def create_small_matmul_savedmodel(out_dir):
"""Create a SavedModel that performs a small matmul."""
root = autotrackable.AutoTrackable()
root.f = def_function.function(
lambda x, y: math_ops.matmul(x, y), # pylint: disable=unnecessary-l
Community Discussions
Trending Discussions on small
QUESTION
I'd like to provide a view for a customer data structure, with it's own iterator. I wrote a small program to test it out, shown below. It I uncomment begin(), then it works. But if I use DummyIter, then I get a compile error.
In my full program, I've implemented a full iterator but for simplicity, I narrowed it down to the necessary functions here.
...ANSWER
Answered 2022-Mar-18 at 11:01This can't work since return types of your begin
and end
do not match.
So basically those iterators can't be compared to each other.
Prove:
- here is your code with extra static assert
- here is dummy fix which compiles since now same return type is used for
begin
andend
Minimum requirement is that result of begin()
and end()
are comparable. Different types for begin()
and end()
are useful when size of range is not known. Here is nice explanation of sentinel (mentioned in comment).
QUESTION
I need to calculate the square root of some numbers, for example √9 = 3
and √2 = 1.4142
. How can I do it in Python?
The inputs will probably be all positive integers, and relatively small (say less than a billion), but just in case they're not, is there anything that might break?
Related
- Integer square root in python
- Is there a short-hand for nth root of x in Python?
- Difference between **(1/2), math.sqrt and cmath.sqrt?
- Why is math.sqrt() incorrect for large numbers?
- Python sqrt limit for very large numbers?
- Which is faster in Python: x**.5 or math.sqrt(x)?
- Why does Python give the "wrong" answer for square root? (specific to Python 2)
- calculating n-th roots using Python 3's decimal module
- How can I take the square root of -1 using python? (focused on NumPy)
- Arbitrary precision of square roots
Note: This is an attempt at a canonical question after a discussion on Meta about an existing question with the same title.
...ANSWER
Answered 2022-Feb-04 at 19:44math.sqrt()
The math
module from the standard library has a sqrt
function to calculate the square root of a number. It takes any type that can be converted to float
(which includes int
) as an argument and returns a float
.
QUESTION
I've deployed hundreds of function and this is the first time I encounter this issue. Simply, it stops deploying function process, saying:
Unhandled error cleaning up build images. This could result in a small monthly bill if not corrected. You can attempt to delete these images by redeploying or you can delete them manually at https://console.cloud.google.com/gcr/images/[project-name]/us/gcf
The way I deploy is through Firebase CLI command: firebase deploy --only functions:nameOfFunction
Question is what are those images I have to delete? Why? How can I solve it?
...ANSWER
Answered 2021-Aug-01 at 15:56Cloud Functions uses another product called Cloud Build to build the server images that actually get deployed. Those images are stored in Cloud Storage, and that storage is billed to your account.
Read more about it:
- https://github.com/firebase/firebase-tools/issues/3404
- https://krasimirtsonev.com/blog/article/firebase-gcp-saving-money
Watch:
You should be able to locate and delete the files manually in the Google Cloud console. But it sounds like there is a bug here with the files not being cleaned up automatically, so you contact Firebase support directly.
QUESTION
In vuejs2 app having select input with rather big options list it breaks design of my page on extra small devices. Searching in net I found “size” property, but that not what I I need : I want to have dropdown selection, which is the default. Are there some other decision, maybe with CSS to set max-height of dropdown selection area.
Modeified PART # 1: I made testing demo page at http://photographers.my-demo-apps.tk/sel_test it has 2 select inputs with custom design and events as in this example link How to Set Height for the Drop Down of Select box and following workaround at js fiddle:
...ANSWER
Answered 2022-Jan-15 at 16:00Unfortunately, you cannot chant the height of a dropdown list (while using ).
It is confirmed here.
you can build it yourself using divs & v-for (assuming you get the list from an outsource) and then you can style it as you wish.
apologies for barring bad news.
QUESTION
I am trying to setup a very small GraphQL API using NestJS 8. I installed all required redepndencies from the documentation, but when I start the server, I get this error:
...ANSWER
Answered 2021-Nov-16 at 02:14I was receiving the same errors.
After debugging step by step, the answer is that @nestjs/graphql@9.1.1
is not compatible with GraphQL@16
.
Specifically, GraphQL@16
changed the gqaphql
function, as called from within graphqlImpl
, to only support args without a schema:
QUESTION
I have a small loop of code which is throwing Uncaught RangeError: Invalid Array Length
I was able to reproduce it with just this in the Google Chrome console
...ANSWER
Answered 2021-Dec-02 at 16:18The real reason is in V8 memory optimization. When you store integers - it stores the 32 bit number in place, But when you store double-number - it is stored differently (as an object) - so yValues
array contains the reference but the actual value stored in heap. So in your example you just used all heap memory. To see the limit, use: console.memory
and you'll see something like this:
QUESTION
I am trying to find a more efficient solution to a combinatorics problem than the solution I have already found.
Suppose I have a set of N objects (indexed 0..N-1) and wish to consider each subset of size K (0<=K<=N). There are S=C(N,K) (i.e., "N choose K") such subsets. I wish to map (or "encode") each such subset to a unique integer in the range 0..S-1.
Using N=7 (i.e., indexes are 0..6) and K=4 (S=35) as an example, the following mapping is the goal:
0 1 2 3 --> 0
0 1 2 4 --> 1
...
2 4 5 6 --> 33
3 4 5 6 --> 34
N and K were chosen small for the purposes of illustration. However, in my actual application, C(N,K) is far too large to obtain these mappings from a lookup table. They must be computed on-the-fly.
In the code that follows, combinations_table
is a pre-computed two-dimensional array for fast lookup of C(N,K) values.
All code given is compliant with the C++14 standard.
If the objects in a subset are ordered by increasing order of their indexes, the following code will compute that subset's encoding:
...ANSWER
Answered 2021-Oct-21 at 02:18Take a look at the recursive formula for combinations:
Suppose you have a combination space C(n,k)
. You can divide that space into two subspaces:
C(n-1,k-1)
all combinations, where the first element of the original set (of lengthn
) is presentC(n-1, k)
where first element is not preset
If you have an index X that corresponds to a combination from C(n,k)
, you can identify whether the first element of your original set belongs to the subset (which corresponds to X
), if you check whether X
belongs to either subspace:
X < C(n-1, k-1)
: belongsX >= C(n-1, k-1)
: doesn't belong
Then you can recursively apply the same approach for C(n-1, ...)
and so on, until you've found the answer for all n
elements of the original set.
Python code to illustrate this approach:
QUESTION
ANSWER
Answered 2021-Nov-20 at 10:52So the solution is quiet simple. All I had to do is using a Webpack plugin.
The best Plugin to fit this task is NormalModuleReplacementPlugin
which is provided out of the box by Webpack itself.
The exclude
in tsconfig.ts
is no longer reasonable within this solution.
Simply provide the following plugin:
QUESTION
I have a vector of random positive integers. I would like to select only those elements of the vector whose sum will be exactly equal to a certain predetermined value.
Let's take an example like this.
x=1:5
, I am looking for elements whose sum is equal to 14
. The solution is of course the vector c(2, 3, 4, 5)
.
Of course, there may be several solutions.
Example 2.
x=1:5
, I'm looking for elements whose sum is equal to 7
.
Here, of course, should be the following three solutions:
1.c(2, 5)
,
2.c(3, 4)
,
3.c(1, 2, 4)
.
There may also be a situation where there will be no solutions at all.
Example 3.
x=c(1, 2, 7)
, I'm looking for elements whose sum equals 5
.
Of course, there are no correct solutions here.
Everything seems trivially simple if we have vectors of several elements. Here, I even came up with a few alternative solutions. However, the problem becomes when the size of the vector increases.
My vector looks like this:
...ANSWER
Answered 2021-Oct-17 at 22:02This task sounds like a 1 dimensional bin packing problem or knapsack problem, in which case there are many resources available online to help guide you.
One potential solution is to use the gbp package, e.g.
QUESTION
In short:
I have implemented a simple (multi-key) hash table with buckets (containing several elements) that exactly fit a cacheline. Inserting into a cacheline bucket is very simple, and the critical part of the main loop.
I have implemented three versions that produce the same outcome and should behave the same.
The mystery
However, I'm seeing wild performance differences by a surprisingly large factor 3, despite all versions having the exact same cacheline access pattern and resulting in identical hash table data.
The best implementation insert_ok
suffers around a factor 3 slow down compared to insert_bad
& insert_alt
on my CPU (i7-7700HQ).
One variant insert_bad is a simple modification of insert_ok
that adds an extra unnecessary linear search within the cacheline to find the position to write to (which it already knows) and does not suffer this x3 slow down.
The exact same executable shows insert_ok
a factor 1.6 faster compared to insert_bad
& insert_alt
on other CPUs (AMD 5950X (Zen 3), Intel i7-11800H (Tiger Lake)).
ANSWER
Answered 2021-Oct-25 at 22:53The TLDR is that loads which miss all levels of the TLB (and so require a page walk) and which are separated by address unknown stores can't execute in parallel, i.e., the loads are serialized and the memory level parallelism (MLP) factor is capped at 1. Effectively, the stores fence the loads, much as lfence
would.
The slow version of your insert function results in this scenario, while the other two don't (the store address is known). For large region sizes the memory access pattern dominates, and the performance is almost directly related to the MLP: the fast versions can overlap load misses and get an MLP of about 3, resulting in a 3x speedup (and the narrower reproduction case we discuss below can show more than a 10x difference on Skylake).
The underlying reason seems to be that the Skylake processor tries to maintain page-table coherence, which is not required by the specification but can work around bugs in software.
The DetailsFor those who are interested, we'll dig into the details of what's going on.
I could reproduce the problem immediately on my Skylake i7-6700HQ machine, and by stripping out extraneous parts we can reduce the original hash insert benchmark to this simple loop, which exhibits the same issue:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install small
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page