text:
# angular momentum of rod

by kuyt
Tags: angular moment, centre of mass, hinged, rod, rotating
 P: 8 What is the angular momentum of a rod rotating about one end (mass M and angular velocity ш),about its center of mass?
Mentor
P: 40,905
 Quote by kuyt What is the angular momentum of a rod rotating about one end (mass M and angular velocity ш),about its center of mass?
Is the rod rotating about one end or its center of mass?
P: 61

## angular momentum of rod

A little research is in order.
http://scienceworld.wolfram.com/physics/
http://hyperphysics.phy-astr.gsu.edu/hbase/hframe.html
"There is no need to know all the answers when you know how to find all the answers that have been found before."
 P: 8 But this is something fundamental,calculating angular momentum of a system about arbitary points in space.
 P: 61 In the second link the 'bubbles' are hot links. Navigate through "Mechanics", then "Rotation", then "Moment of Inertia". Click on "Common Forms" for Enlightenment!
 P: 208 Find the angular momentum of a differential length (dm*v*r) and integrate from r=0 to L.
Math
Emeritus
Thanks
PF Gold
P: 38,899
 Quote by kuyt But this is something fundamental,calculating angular momentum of a system about arbitary points in space.
Yes, it is, and you can answer it by calculating the angular momentum of individual point about the end of the rod, then integrating them along the length of the rod. The result of doing that would be the formula at http://scienceworld.wolfram.com/phys...nertiaRod.html
that you could get to following the links you were given in tadchem's response.
P: 8
 Quote by HallsofIvy Yes, it is, and you can answer it by calculating the angular momentum of individual point about the end of the rod, then integrating them along the length of the rod. The result of doing that would be the formula at http://scienceworld.wolfram.com/phys...nertiaRod.html that you could get to following the links you were given in tadchem's response.
it gives moment of inertia not angular momentum! Can we use the general formula(if its correct):angular moment abt any point=angular moment of a fictitious particle (of mass m at the position of COM)abt that point + angular moment of the body abt com ?
 P: 58 hello kuyt, i think you should have a look at the angular momentum equation ie., L= r X P and v=rw. So, use r=l/2 where l=length of rod. hope that makes sense..
 P: 8 No,it not that easy I guess. P.S can anyone giveme the final answer(in terms of angular velocity,mass and length)and ofcourse the explanation,instead of links
 P: 208 It's (1/3)wmL^2 for angular speed w.
 P: 8 ^but that about one of the ends ,not com
 HW Helper P: 3,339 Ah, so you're trying to find the angular momentum about the com, in a system where the rod is rotating about one end.
 P: 8 yes
 HW Helper P: 3,339 hmm. Tricky one. Well, I'm pretty sure that the whole point of saying the angular momentum "about a point" is equivalent to calculating the angular momentum, given that the origin is the point about which we want to find the angular momentum. So I think the angular momentum about the COM is simply angular momentum, given that our origin is the COM. And in our original reference frame, the rod was rotating around the end. So in a reference frame where the COM stays at the origin, the angular momentum will simply be $$\omega \frac{mL^2}{12}$$ (in other words, same as what the angular momentum would be for a system where the rod is rotating around it's COM.)
 Admin P: 21,637 The links provide helpful information. Students are expected to demonstrate effort and show their work. We do not spoon feed students with answers.

 Related Discussions Introductory Physics Homework 0 Introductory Physics Homework 0 Introductory Physics Homework 2 Introductory Physics Homework 12 Introductory Physics Homework 3


text:
# No more “unknown” icons

In recent versions of Dolphin, the view sometimes looked like this just after entering a directory.

Some of the files and sub-directories have “unknown” icons, which are replaced by the correct icons later.

This will not happen any more in Dolphin 4.11.

# Why did we show you “unknown” icons at all in the first place?

Dolphin can show you a lot of information about your files. Some of this information can be obtained quite easily, like, e.g., the name, the file size, and the modification time.

However, some other properties of a file or directory might be more expensive to determine. Examples are:

• The type of a file: if it cannot be determined unambiguously from the file name, we have no choice but to read the contents of the file.
• The icon that has to be shown for a file depends on the type. A directory icon, on the other hand, can be chosen by the user in the “Properties” dialog. The chosen custom icon is then stored in a file named “.directory” inside the directory, so determining the icon for a directory always requires a disk access (because we don’t know in advance if there is a .directory file or not).
• If previews are enabled, the preview for each item has to be retrieved from the .thumbnails directory in your home folder. If no cached preview can be found there, it gets worse, and the (possibly large) file must be read from disk to generate a new preview image.
• Counting the number of files inside a directory also requires a disk access. It is shown, e.g., in the “Size” column in Details View.
• Meta data provided by Nepomuk.

To make things more complicated, some of these properties can have “preliminary” and “final” values. For example, the preliminary icon for any directory is the generic “folder” icon, but the final icon is only known after checking the contents of the corresponding .directory file.

We obviously cannot determine the final values of all these properties synchronously, i.e., blocking the application’s main thread, for all files and directories. In large directories, it might take very long until this process is finished. Therefore, we have to find some compromise between “show the items in the view as quickly as possible” and “only show any kind of information if we know what its final state is”.

# What happened in earlier Dolphin versions

We have a class called KFileItemModelRolesUpdater (.h, .cpp) which is responsible for determining the data that are possibly expensive to retrieve.

When you enter a directory, it tries to determine the final icons for the visible items for up to 200 milliseconds. It then then returns to the event loop, such that the view can be painted, mouse events can be processed, etc. The remaining icons and other data are determined asynchronously – first for the visible items in ascending order, then for all invisible ones in random order. We still do it in the main thread, but only for one item at a time, such that it never blocks for too long until the next events can be processed. Moreover, the asynchronous processing of the remaining items is suspended if the view is scrolled. This ensures that scrolling feels smooth.

This approach has two downsides:

1. Some “unknown” icons can remain if 200 milliseconds are not sufficient to determine the final icons for all visible items. This can happen easily if there are many directories in the view, whose final icons can only be determined by accessing the contents of the directory.
2. It wastes resources when viewing large directories. Loading previews for thousands of images (I know from user feedback at bugs.kde.org and forum.kde.org that it is not uncommon to have hundreds of thousands of images in one directory) can easily make the hard drive and the CPU busy for a few minutes, even though it is very unlikely that the user will ever scroll through all these images in the view. Moreover, the previews need a lot of memory.

# Improvements in Dolphin 4.11

KFileItemModelRolesUpdater still only tries to load the final icons for 200 milliseconds. However, just before an item is shown on the screen, Dolphin will check if its final icon has been determined already. If that is not the case, it will use the “preliminary” icon, which can be determined very fast. In many cases, the preliminary icons are actually equal to the final ones. Notable exceptions are directories with custom icons, and most of the files in /usr/bin.

Some changes in kdelibs were required to make this possible, see this discussion on the mailing list for details about this, and how “Poor Man’s Profiling” helped to solve the problem. Many thanks to David Faure for his help!

Thanks to this modification, Dolphin will never show you “unknown” icons again for items which do have a valid icon.

Moreover, Dolphin will not try to load icons/previews/etc. for all items in the directory asynchronously any more. It will just do that for the items which are currently visible, and those which can be reached quickly by scrolling up or down a few pages or to the top or bottom of the view (up to 500 at a time).

This greatly reduces the amount of memory and CPU cycles that we use to load and show a directory.

Some more information about the code changes that were required for this can be found in the corresponding review requests: 1, 2, 3, 4, 5, 6.

# Some thoughts on algorithmic complexity, part 2: Be careful if you insert into or remove from a std::vector, QVector, or QList in a loop

This is the second part of a series of blog posts. Like in part 1, most or all of what I write here will be obvious to many readers. However, I have seen problems which are equivalent to those that I show here more than once in widely-used code, so I think it makes sense to make people aware of these issues and possible solutions.

If you are familiar with containers like std::vector already, feel free to skip the introduction.

# Introduction

Different kinds of data structures, also called containers, are a core part of most applications. Depending on the programming language, various containers are provided by the language itself, by libraries which are shipped with the compiler (like the STL in the case of C++), or by libraries like Qt. Containers like vectors, linked lists, sets, hashes, etc., have quite different properties. Each container has advantages in some situations and disadvantages in others. If you want to know more about these, you might want to have a look at the relevant page in the Qt docs or the “Containers” page at cppreference.com for a general overview, or a Qt quarterly article and an excellent article by Marc Mutz for some very interesting details.

## QVector, QList, and std::vector

In this post, I will focus on containers which store their elements in one contiguous block of memory. These have the following useful properties:

• The items have a well-defined order (this is not the case, e.g., in a QSet).
• Each item has an integer index: the item stored at the beginning of the block has the index 0, the next one has the index 1, and so on. Moreover, accessing an item with a certain index is very fast, no matter how many items there are. It takes O(1), or constant, time, in contrast to linked lists, which also have a well-defined order, but require O(N) time to access a particular element.
• Appending items at the end also needs constant time. The containers reserve some free space at the end to make sure that appending many items one by one will not require an expensive memory reallocation every time. Removing the last item also needs constant time.

However, inserting or removing items at a random position takes O(N) time because all items after the inserted/removed item (on average, that is N/2 items) have to be moved.

## Special case: QList

One important difference between QList and the other two containers is that it does not store the items themselves in the contiguous block of memory if an item requires more size than a pointer. It rather stores pointers to the actual items in the contiguous block then. Moreover, it never uses less than the size of a pointer (4 or 8 bytes on a 32-bit or 64-bit platform, respectively) for an item. These properties can be beneficial in some situations (for example, it enables QLists with different data types to share much of their code in the binary, and it makes moving large items inside the list faster), but storing many bools in a QList might waste a lot of memory.

Another difference is that QList can even add items at the beginning or remove the first item in O(1) time because it also reserves some memory at the beginning. When inserting/removing at a random position, it checks if there are less items to the left or to the right and moves the smaller part of the memory block. Therefore, only N/4 items have to be moved on average, but that is still O(N).

# Removing many items can be very slow if implemented incorrectly

Let’s assume that we have stored some items of a type T in a QVector, and we have to remove all items for which a function filter(T) returns true.

Simple example: remove all odd numbers from a QVector with many numbers.

A possible solution would be to go through all numbers and remove any odd number that we find:

```template<class Container, class Filter>
void remove1(Container& c, Filter filter)
{
auto it = c.begin();

while (it != c.end()) {
if (filter(*it)) {
it = c.erase(it);
} else {
++it;
}
}
}
```

To test the efficiency of the function, I wrote a small benchmark that creates a sorted QVector containing the integers between 1 and N, and then removes either the first half or the second half of these numbers, or all odd numbers. The results are shown in this plot (the y-axis shows the time in milliseconds):

It turns out that the function is quite inefficient and has O(N^2) complexity in all test cases. The reason should be clear: every time an item is removed, all items after that one are moved one position to the front. In other words, O(N) items are moved O(N) times, so we get O(N^2) behaviour. What actually happens is shown here:

Note that we could fix the “remove many items from the end” case by going through the items in reverse order (remember that removing the last item is fast). However, this would not help much in the other cases.

## Good solution 1

Rather than moving all following items one position to the front when an item is removed, we could just replace it with the last item. This guarantees that removing a single item will always cause at most one other item to be moved:

```template<class Container, class Filter>
void remove2(Container& c, Filter filter)
{
auto it = c.begin();
auto end = c.end();

while (it != end) {
if (filter(*it)) {
--end;
*it = std::move(*end);
c.erase(end);
} else {
++it;
}
}
}
```

The new function has linear complexity for all types of test cases:

The obvious disadvantage is that the relative order of the items is not preserved. However, if the order does not matter, then this solution might be worth considering, in particular if only a few items have to be removed (note that removing a single item is always O(1) with this solution).

## Good solution 2

We can achieve linear complexity and still preserve the sort order. The solution is to make sure that every item is moved at most once: we move an item to the front only when its final position is known.

Implementing this idea is quite straightforward, but it’s not even necessary, because this is just what std::remove_if does.

```template<class Container, class Filter>
void remove3(Container& c, Filter filter)
{
const auto oldEnd = c.end();
const auto newEnd = std::remove_if(c.begin(), oldEnd, filter);
c.erase(newEnd, oldEnd);
}
```

In our test cases, this is faster than the “replace by the last item” solution by a factor of 2:

# Final remarks

• If you insert many items into an existing std::vector, QVector, or QList, similar considerations apply.
• Such problems really do exist in the software you use, even though they might not cause any serious trouble as long as you don’t let applications handle a large data set that triggers the worst case behaviour. I’ve fixed a few such problems in Dolphin recently, and I will tell you about more problems of this kind in the next post.
• Thanks for all the interesting feedback that I got after my last post! In particular, I would like to mention Emilio Coppa from the University of Rome here. He works on aprof, a Valgrind-based tool that can help to find inefficient functions like those that I presented here. Just run your program inside this tool and make sure that all interesting functions are fed with various amounts of input data. I ran my benchmark in aprof (I just made it consider a larger set of different vector sizes to make the output look nicer and decreased the overall size of the vectors to reduce the runtime on Valgrind’s simulated CPU). Here is the visualization of the output for the function remove1:

And the same for remove2:

Note that you don’t have to write a benchmark at all to get such results with aprof. You can just run your application normally, make sure that it handles inputs with different sizes, and then you can spot the inefficient functions quite quickly (provided that you trigger the inefficient behavior of these functions). If you want to know how the tool works, have a look at this paper. It found a bug that was basically just the strlen issue that I discussed in my last post in the word frequency counter “wf”.
• Just to prevent misunderstandings: I’m not saying that algorithms with O(N^2) worst-case complexity are always evil. If it is guaranteed that N will never get really large or that the input data will never trigger a bad worst-case behaviour, then there may be reasons why such an algorithm might be preferable.

# Dolphin bugs fixed in June 2013

The last bug fix update for Dolphin 2.2 has been shipped recently. Here is a summary of the changes that you can enjoy if you upgrade:

• Bug 320823: Rename the right item when items are added to the view while renaming. See git commit 4de9a233, review request 110909.
• Bug 319912: Do not rename files unexpectedly when changing the URL while renaming. See git commit 5948dc0f, review request 110908.
• Bug 310705, bug 312014: Ensure that switching to “Sort by Type” takes effect without reloading the view. See git commit 735c046d, review request 111004.
• Bug 320897: Prevent that the rubber band selection rectangle gets a width or height of zero pixels. See git commit 22d93e8f, review request 111144.
• Bug 321234: Allow renaming multiple files without providing one or more ‘#’ as a placeholder for a number if all extensions are different. This was an “accidental” feature that we were not aware of at all until a user reported that it had been broken by a recent bug fix. See git commit 6f2e1403, review request 111079.
• Bug 316209: Prevent possible infinite recursion in the ViewProperties constructor, which caused crashes on MacOS. See git commit 04229f8f, review request 111182.
• Bug 307336: When dragging a file from a search result to KMail, use the correct URL. See git commit c847aacf, review request 111209.
• Bug 321198: Make searching recent files work correctly. See git commit 25a2255e.

Moreover, Dawit Alemayehu, who has fixed an amazing number of kdelibs bugs that affect file management, made two more commits last month which:

These improvements were contributed and/or tested by Dawit Alemayehu, Emmanuel Pescosta, Kurt Hindenburg, and Vishesh Handa. Thanks for your help! If I forgot anyone, please let me know.

Unfortunately, I’m unable to attend Akademy, but I hope that everyone who is in Bilbao has a good time there!

# Dolphin bugs fixed in May 2013

Again, we have a new bug fix release. Here are the bug fixes that Dolphin users who upgrade can benefit from:

• Bug 304918: Update the ‘Recently Accessed’ and ‘Search For’ sections of the Places Panel when Nepumuk is started or stopped. See git commit 24609e78, review request 110323.
• Bug 255819: Ensure that manual changes of the icon for the ‘Sort By’ toolbar button are remembered. See git commit f12345a5, review request 109966.
• Bug 319660: When dropping the trash in a directory, create a link, rather than copying the trash contents to that directory. See git commit 6072f58c.
• Bug 319747: Fix crash when copying many files. See git commit 1b9726e2.
• Bug 315796: Make it possible to change the parameters of ‘read only’ search queries. See git commit 2c68fe33, review request 110324.
• Bug 309740: Prevent that files in expanded folders are shown with a size of 16 EiB while they are being changed. See git commit 56cf52db, review request 110428.
• Bug 299675: Fix problems when moving files out of or into expanded folders in Details View. See git commit a79c3a39, review request 110401.
• Bug 319336: Fix a crash that could happen when editing the tags of a file. See git commit 2080bc1d.

Thanks to Daniel Faust, David Faure, and Vishesh Handa!

# Some Thoughts On Algorithmic Complexity, Part 1

When people develop and maintain software, they usually try to make sure that their code not only works well, but also that it runs fast. There are many different ways to make code perform better. It can be as simple as choosing reasonable compiler options, or as hard as rewriting some code in assembly.

If you see some code that takes long to run, you should not start optimizing by looking into the little details though. The first questions that you should ask is: are we actually using the right algorithm for the job? Are there any design mistakes that make things much worse than they need to be? This is especially important if you don’t know in advance how much input the code will have to handle. It should be obvious that it makes a difference if a list that needs to be sorted contains 1000 or 1 million items. However, how big that difference actually is depends on the choice of the algorithm and its correct implementation.

If you are not interested in mathematics or theoretical computer science, feel free to skip the next sections. Maybe the example programs at the end of the post will be interesting for you nonetheless, at least if you are fairly familiar with programming.

Big O notation

The exact time f(N), measured in milliseconds, CPU cycles, or some other suitable unit, that an algorithm requires if it is given an input of size N (N could be the length of a list or the length of a string, for example) is often less interesting than the growth rate, i.e., how fast that time grows if N becomes larger and larger. Is it constant, or does it increase logarithmically, linearly, or even worse?

To classify the so-called run-time complexity of an algorithm, one often uses the big-O notation. It can be used to provide an upper limit for f(N) in a rather simple way, even if writing down f(N) exactly would yield a very complex expression. The idea is to use a simple function g(N), and say that

$f(N)=O(g(N))$

if there is a constant c such that

$f(N)\le c\, g(N)$

for any N, i.e., if this constant times g(N) is an upper bound for f(N). Simple example: if

$f(N)=4 N+\log_2(N)+2,$

we could write f(N)=O(N) because the linear term 4 N is the one which grows fastest, such that the total value f(N) is always smaller than some constant times N.

Typical orders (of growth) that often occur in algorithms in the software that we use include O(1), O(log N), O(N), and O(N log N).

I’ll give some examples for situations where these occur:

 $O(1)$ constant: a simple example in the Dolphin context would be showing the files and folders on the screen. Even if you have 100,000 items in a directory, only a small, constant number of them can be shown at the same time, so the effort required to draw them should not depend on N at all. $O(\log N)$ logarithmic: the classical example is binary search. If you are given a sorted list of N items, and you have to find a particular item, you might start by looking at the element in the middle. This tells you if you have to look at the first or in the second half of the list. It is easy to show that applying this procedure repeatedly will yield the right item in $\log_2 N$ steps. $O(N)$ linear: a Dolphin example would be loading the data for all files in a directory (like the name, size, and other things that we might want to show in the view). $O(N \log N)$ If a good sorting algorithm is used to sort a list of N items, this is the typical number of comparisons of two items that are required, and hence, also a measure of the time that will be needed to sort the list. $O(N^2)$ quadratic: this is something that you really want to avoid, unless you can guarantee that you will never have to handle really many items, or there really is no better solution for your problem. If you are not sure if a better solution exists, you should look for one. Really.

Best case, average case, and worst case

Things are often a bit more complicated: the run-time complexity of an algorithm can depend on the actual input data. For example, certain sorting algorithms might work better if the input data are (almost) sorted, and worse for certain other kinds of data.

Therefore, one often states the best case, average case, and worst case run-time complexity of an algorithm. Which of these is most important depends strongly on what you know in advance about the input data. If they are always in a certain form, an algorithm that has a good best-case performance just for that kind of data might be preferable. On the other hand, if the input data might come from an untrusted source, ensuring a reasonable worst-case performance should have the highest priority if you want to prevent that you and your users will be the target of algorithmic complexity attacks.

Why am I telling you all this?

This is an obvious question that you might ask now. Everyone who develops software should be familiar with those things already, right? Well, it turns out that a lot of real-world code does have a worst-case (or, sometimes, even an average) run-time complexity that is worse than it needs to be, either because the wrong algorithm has been chosen, or because a tiny mistake in the implementation makes things go terribly wrong if a certain kind of input is fed into the algorithm. This is why I thought it might be a good idea to write a series of blog posts to raise people’s awareness of these issues.

Example

Let’s start with a simple example, and assume that we have to write a function that replaces all occurrences of a certain character in a plain C string by another character. E.g., replace ‘u’ by ‘o’ in the string ‘algurithm’ to obtain the right spelling ‘algorithm’. Let us also ignore that we don’t actually use plain null-terminated C strings much in KDE/Qt code, and that solutions for this problem exist already.

Any algorithm to solve this problem will have to go through all N characters of the string once, and look at and possibly replace each character. So we would expect that the run-time complexity is O(N).

This is a possible solution that we could come up with:

```void replace1(char* text, char oldChar, char newChar)
{
for (unsigned int i = 0; i < strlen(text); ++i) {
if (text[i] == oldChar) {
text[i] = newChar;
}
}
}
```

Some will already see the flaw in this implementation, but I assume that many would just verify that this function works nicely for a few examples and then happily use it. It might even work OK in real world applications for some time, that is, until someone uses this function to handle a very long string.

A small benchmark that tests this function for strings with lengths between 100,000 and 800,000 characters can be found in my personal KDE scratch repository. The following plot shows the time in milliseconds as function of the input size (plots were generated with qtestlib-tools).

When you see this plot, you immediately realize that the time depends quadratically on the input size. So our algorithm has a run-time complexity of O(N^2), rather than the expected O(N). This results in an unacceptable run time of 8 seconds just for going through 800,000 characters and replacing some of them! If you are doing something like this in the main thread of an application, the GUI will be completely frozen during that time.

What went wrong?

The problem is the condition ‘i < strlen(text)’ in the for loop. This condition is evaluated after each execution of the loop, i.e., N times. Moreover, strlen(text) must go through the entire string, because it looks for the terminating null character, which defines the end of the string. This means that the O(N) function strlen(const char*) is executed N times. Now it is obvious why our function is O(N^2).

Correcting the mistake

Here is a better version of the function, and benchmark results that show that it needs only linear time. Note that the time to handle 800,000 characters has been reduced from 8 seconds to 1.5 milliseconds:

```void replace2(char* text, char oldChar, char newChar)
{
const unsigned int length = strlen(text);
for (unsigned int i = 0; i < length; ++i) {
if (text[i] == oldChar) {
text[i] = newChar;
}
}
}
```

Maybe some readers will now ask if an optimizing compiler shouldn’t be able to see that calculating the length of the string repeatedly is unnecessary, and thus optimize the first version of our code such that it becomes O(N). It turns out that such an optimization is impossible because using our function to replace any char by 0 will actually change the length of the string inside the loop.

Do professional developers really write code which has such problems?

Yes, they do. According to an article that I once read on the web (I cannot find it at the moment, unfortunately – if you do, please add a comment!), the “strlen in for loop condition” issue once caused huge problems in the computer system of a bank. Moreover, there is still a lot of code out there which has similar problems, even if they are sometimes less obvious. In the next posts in this series, I’ll tell you about some further examples, which will be fixed in KDE 4.11.

# Dolphin bugs fixed in April 2013

Here are the bugs which were fixed in Dolphin for last week’s release:

• Aureliéns efforts to make our hover animation as good as possible were not over yet: one little bug remained after his recent fixes. For details, see git commit c3a7ba4e, review request 109960.
• Bug 316129: When entering a directory, load the icons for the visible icons first, rather than loading all icons in random order. See git commit 52a38ee9, review request 109843.
• Bug 317827: Fix possible crash when filtering items. See git commit 34d0ad72.
• Bug 316285: Fix crash in the accessibility code. See git commit f8bf2577.
• Bug 317772: Disable the non-working Find/Replace actions when renaming inline. See git commit a16562cd.
• Bug 193298: Make sure that the correct free space for the current device is shown when viewing a folder with a name whose beginning coincides with a mount point. See git commit 4f2ecbab, review request 110225.
• Bug 318942: When renaming multiple files, make sure that the “Rename” button is enabled if and only if there is exactly one connected sequence of ‘#’ symbols. See git commit cbb2a4cf, review request 110223.
• Bug 305734: Fix the problem that selected hidden items are hard to see with certain color schemes. See git commit 572513a1, review request 110164.
• Bug 302037: Prevent that the view URL changes unexpectedly when the Terminal Panel is enabled and the current path is a symbolic link to a directory. See git commit 2e123de9, review request 110233.

Thanks for providing patches, helpful analysis and testing proposed fixes: Aurélien Gâteau, David Faure, Emmanuel Pescosta, and Jekyll Wu.

format: plain


text:
Keras Weighted Categorical Cross Entropy Loss Categorical Cross-Entropy Loss, Binary Cross-Entropy Loss 有时候你用交叉熵发现损失值很低但是识别效果就是不好这可能是因为你有多个分类但是却用二元交叉熵的原因。. Therefore, the final loss is a weighted sum of each loss, passed to the loss parameter. Operations are recorded if they are executed within this context manager and at least one of their inputs is being "watched". Use sparse categorical crossentropy when your classes are mutually exclusive (e. if you have 10 classes, the target for each sample should be a 10-dimensional vector that is all-zeros except for a 1 at the index corresponding to the class of the sample). It is intended for use with binary classification where the target values are in the set {0, 1}. What we've covered 🤔 How to write a classifier in Keras 🤓 configured with a softmax last layer, and cross-entropy loss 😈 Transfer learning 🤔 Training your first model 🧐 Following its loss and accuracy during training; Please take a moment to go through this checklist in your head. when each sample belongs exactly to one class) and categorical crossentropy when one sample can have multiple classes or labels are soft probabilities (like [0. Artificial Neural Networks are developed by taking the reference of Human brain system consisting of Neurons. In plain English, I always compare it with a purple elephant 🐘. Then cross entropy (CE) can be defined as follows: In Keras, the loss function is binary_crossentropy(y_true, y_pred) and in TensorFlow, it is softmax_cross_entropy_with_logits_v2. But now I want to re-use this code and convert this code to binary case where I say if an image. 關於這兩個函數, 想必. 5, class 2 twice the normal weights, class 3 10x. : Kerasの方法 "evaluate"を使って計算された正確さは単なる明白です binary_crossentropyを2つ以上のラベルで使用すると間違っています。. Keras is a high-level library that is available as part of TensorFlow. 95) Adadelta optimizer. A look at the Layer API, TFLearn, and Keras. Replacing the maxplooling layers and using leaky ReLU in CNN model 2 slightly decreased the precision. It is used for multi-class classification. Read its documentation here. Does the activation of dense layer achieve it already and categorical cross entropy just gets neg log or do I need to define it in some other way? The loss is shown in list as I apply another loss later. from keras import metrics model. For example, given a dataset containing 99% non-spam. This is because the right hand side of Eq. Last Updated on January 10, 2020 Model averaging is an ensemble technique Read more. (그러므로 feature 갯수 by label class 갯수인 테이블이 된다. これはsigmoid_cross_entropy_with_logits()を除いてsigmoid_cross_entropy_with_logits()と似ていますが、負のエラーと比較して正のエラーのコストをアップまたはダウン加重することでリコールと精度をトレードオフできます。. The goal of our machine learning models is to minimize this value. We compile our model and use the Adam Optimizer and the sparse categorical cross-entropy as a loss. The following are code examples for showing how to use keras. This blog post shows the functionality and runs over a complete example using the VOC2012 dataset. The scaling factor T is learned on a predefined validation set, where we try to minimize a mean cost function (in TensorFlow: tf. You received this message because you are subscribed to a topic in the Google Groups "Keras-users" group. Adadelta is a more robust extension of Adagrad that adapts learning rates based on a moving window of gradient updates, instead of accumulating all past gradients. Cross-entropy is a measure of the difference between two different distributions: actual and predicted. With my simple training code below, I was classifying 10 classes. It is a problem where we have k classes or categories, and only one valid for each example. You would use categorical cross-entropy as your loss function and you would change classes=4 in the LeNet instantiation. In Keras we have binary cross entropy cost funtion for binary classification and categorical cross entropy function for multi class classification. 针对端到端机器学习组件推出的 TensorFlow Extended. An Intro to High-Level Keras API in Tensorflow. Use sparse categorical crossentropy when your classes are mutually exclusive (e. sparse_categorical_crossentropy(y_true, y_pred) to re-weight the loss according to the class which the pixel belongs to?. We have used loss function is categorical cross-entropy function and Adam Optimizer. The standard weighted categorical cross-entropy loss is The control neural networks used the standard Keras binary cross-entropy loss function, which wraps the TensorFlow implementation. 407 4 4 silver badges 12 12 bronze views Custom cross entropy loss function. Then cross entropy (CE) can be defined as follows: In Keras, the loss function is binary_crossentropy(y_true, y_pred) and in TensorFlow, it is softmax_cross_entropy_with_logits_v2. A Neural Network is a network of neurons which are interconnected to accomplish a task. If sample_weight is a tensor of size [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the sample_weight vector. Binary Cross-Entropy / Log Loss. This comment has been minimized. A list of available losses and metrics are available in Keras’ documentation. The following are code examples for showing how to use keras. Categorical Cross-Entropy loss. If sample_weight is a tensor of size [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the sample_weight vector. Generate batches of tensor image data with real-time data augmentation. k_clear_session. Binary Cross Entropy: When your classifier must learn two classes. If a have binary classes with weights = [0. issue in categorical_crossentropy (keras) and softmax_cross_entropy_with_logits (tensorflow) #7558 Closed KeqiangWang opened this issue Aug 8, 2017 · 1 comment. h5 using model. With my simple training code below, I was classifying 10 classes. def weighted_categorical_crossentropy (weights): """ A weighted version of keras. The goal of our machine learning models is to minimize this value. Categorical cross entropy loss = $\sum_{i=1}^K y_i log(p_i)$ I want to give. 50% for a multi-class problem can be quite good, depending on the number of classes. Lines 111-113 compile our model with the Adam optimizer, a learning rate decay schedule, and binary cross-entropy. To minimize the loss, it is best to choose an optimizer with momentum, for example AdamOptimizer and train on batches of training images and labels. pipeline import Pipeline #from keras. It'll be better to use one_weight=0. where w_i is the smart weight. Built-in metrics. To the beginner, it may seem that the only thing that rivals this interest is the number of different APIs which you can use. Last Updated on January 10, 2020 Model averaging is an ensemble technique Read more. Computes the binary cross entropy (aka logistic loss) between the output and target. If you’d prefer to leave your true classification values as integers which designate the true values (rather than one-hot encoded vectors), you can use instead the tf. For example, binary cross entropy with one output node is the equivalent of categorical cross entropy with two output nodes. Finally, we ask the model to compute the 'accuracy' metric, which is the percentage of correctly classified images. In this tutorial, I will give an overview of the TensorFlow 2. k_categorical_crossentropy. The target values are still binary but represented as a vector y that will be defined by the following if the example x is of class c :. The loss for input vector X_i and the corresponding one-hot encoded target vector Y_i is: We use the softmax function to find the probabilities p_ij:. The less common label in a class-imbalanced dataset. I read some stack overflow posts that say to use the keras backend but I can't find any good resources on how the Keras backend functions work. In the context of support vector machines, several theoretically motivated noise-robust loss functions. The main advantage of the "adam" optimizer is that we don't need to specify the learning rate, as is the case with gradient descent. I'm new to Deep Learning and Keras. The APIs for neural networks in TensorFlow. Keras supplies many loss functions (or you can build your own) as can be seen here. $\endgroup$ - Nickpick Feb 7 '18 at 23:28. The traditional CNN. target – Tensor of the same. Parameters. In the words of Keras' author François Chollet, "Theano and TensorFlow are closer to NumPy, while Keras is closer to scikit-learn," which is to say that Keras is at a higher level compared to. It seems like the tensorflow documentation on weighted cross entropy with logits is a good resource, if its a classification case use the above. A perfect model would have a log loss of 0. Such networks are commonly trained under a log loss (or cross-entropy) regime, giving a non-linear variant of multinomial logistic regression. 4 and doesn't go down further. See Migration guide for more details. $\begingroup$ @Media: Yes it will get updated, because the softmax transform links all the neuron values together, so even though the loss is effectively only calculated on one neuron's output after the softmax is applied, you will still calculate a non-zero gradient value for all the neurons at the pre-softmax linear (logit) stage using back. Need help creating a custom loss function in Keras I'm to create a custom loss function for my NN to train based on the quadratic weighted kappa metric. The model must be trained with two loss functions, binary cross entropy for the first output layer, and categorical cross-entropy loss for the second output layer. The focusing parameter γ(gamma) smoothly adjusts the rate at which easy examples are down-weighted. Customized categorical cross entropy. layers import Conv2D , MaxPooling2D , Input from keras. sample_weight: Optional sample_weight acts as a coefficient for the loss. Derivative of Cross Entropy Loss with Softmax. I'm new to Deep Learning and Keras. 0, the function to use to calculate the cross entropy loss is the tf. As it is a multi-class problem, you have to use the categorical_crossentropy, the binary cross entropy will produce bogus results, most likely will only evaluate the first two classes only. Therefore, the final loss is a weighted sum of each loss, passed to the loss parameter. Weight initialization - We will randomly set the initial random weights of our network layer neurons. $\begingroup$ Oh, I assumed that the OP has instantiated and trained the model previously and saved the model as bottleneck_fc_model. dense layer: a layer of neurons where each neuron is connected to all the neurons in the previous layer. Libraries such as keras do not require this workaround, as methods like "categorical_crossentropy" accept float labels natively. For example, given a dataset containing 99% non-spam. The loss function. input - Tensor of arbitrary shape. So that's good news for the cross-entropy. x, I will do my best to make DRL approachable as well, including a birds-eye overview of the field. In this module, you will learn several types of loss functions like Mean-Squared-Error, Binary-Cross-Entropy, Categorical- Cross-Entropy and others. This blog post shows the functionality and runs over a complete example using the VOC2012 dataset. A loss function (or objective function, or optimization score function) is one of the three parameters (the first one, actually) required to compile a model: We often see categorical_crossentropy used in multiclass classification tasks. View source. The metric creates two local variables, true_positives and false_positives that are used to compute the precision. Keras also supplies many optimisers - as can be seen here. utils import np_utils from itertools import product from keras. Now we use the derivative of softmax that we derived earlier to derive the derivative of the cross entropy loss function. 0001, head=None) Calculate the semantic segmentation using weak softmax cross entropy loss. class AUC: Computes the approximate AUC (Area under the curve) via a Riemann sum. datasets import mnist from keras. Jane Sully. Keras distinguishes between binary_crossentropy (2 classes) and categorical_crossentropy (>2 classes), so we'll use the latter. compute gradient of each hidden-to-output weight 2. Small detour: categorical cross entropy. class: center, middle # Neural networks and Backpropagation Charles Ollion - Olivier Grisel. A Neural Network is a network of neurons which are interconnected to accomplish a task. In the snippet below, each of the four examples has only a single. Intuitively, our affective loss encourages affect-rich words to obtain higher output probability, which effectively introduces a probability bias into the decoder language model towards. Keras has many other optimizers you can look into as well. You can do this by setting the validation_split argument on the fit () function to a percentage of the size of your training dataset. Issues with sparse softmax cross entropy in Keras 24 Mar 2018. This tutorial will cover how to do multiclass classification with the softmax function and cross-entropy loss function. affiliations[ ![Heuritech](images/heuritech-logo. For example, if y_true is [0, 1, 1, 1] and y_pred is [1, 0, 1, 1] then the precision value is 2/(2+1) ie. The equation for binary cross entropy loss is the exact equation for categorical cross entropy loss with one output node. is_categorical_crossentropy(loss) Note : when using the categorical_crossentropy loss, your targets should be in categorical format (e. weak_cross_entropy_2d (y_pred, y_true, num_classes=None, epsilon=0. 0, the function to use to calculate the cross entropy loss is the tf. dN-1] (or can be broadcasted to this shape), then each loss element of y_pred is scaled by the corresponding value of. Adadelta is a more robust extension of Adagrad that adapts learning rates based on a moving window of gradient updates, instead of accumulating all past gradients. From the Keras documentation, "…the loss value that will be minimized by the model will then be the weighted sum of all individual losses, weighted by the loss_weightscoefficients. You would use categorical cross-entropy as your loss function and you would change classes=4 in the LeNet instantiation. 针对端到端机器学习组件推出的 TensorFlow Extended. Last Updated on January 10, 2020 Model averaging is an ensemble technique Read more. If we use this loss, we will train a CNN to output a probability over the classes for each image. Replacing the maxplooling layers and using leaky ReLU in CNN model 2 slightly decreased the precision. If you save your model using model. Instead, we only have prior information (or description) about seen and unseen classes, often in the form of physically realizable or descriptive attributes. From one perspective, minimizing cross entropy lets us find a ˆy that requires as few extra bits as possible when we try to encode symbols from y using ˆy. If you’re building from this training script with > 2 classes, be sure to use categorical cross-entropy. active oldest votes. softmax_cross_entropy_with_logits is currently. After completing this step-by-step tutorial, you will know: How to load data from CSV and make it available to Keras. Now that we have our images downloaded and organized, the next step is to train a Convolutional Neural Network (CNN) on top of the data. Cost functions in machine learning, also known as loss functions, calculates the deviation of predicted output from actual output during the training phase. compile(loss=keras. Converts a class vector (integers) to binary. In this module, you will learn several types of loss functions like Mean-Squared-Error, Binary-Cross-Entropy, Categorical- Cross-Entropy and others. Cost functions are an important part of the optimization algorithm used in the training phase of models like logistic regression, neural network, support vector machine. The MNIST handwritten digit classification problem is a standard dataset used in computer vision and deep learning. You can absolutely work with large datasets. Keras weighted categorical_crossentropy. loss_weights: Optional list or dictionary specifying scalar coefficients (Python floats) to weight the loss contributions of different model outputs. The focusing parameter γ(gamma) smoothly adjusts the rate at which easy examples are down-weighted. More precisely, it trains using some form of gradient descent and the gradients are calculated using Backpropagation. In Artificial Neural Networks perceptron are made which resemble neuron in Human Nervous System. In this tutorial, you will learn how to train a COVID-19 face mask detector with OpenCV, Keras/TensorFlow, and Deep Learning. Visualization of network layers. これはsigmoid_cross_entropy_with_logits()を除いてsigmoid_cross_entropy_with_logits()と似ていますが、負のエラーと比較して正のエラーのコストをアップまたはダウン加重することでリコールと精度をトレードオフできます。. At the same time, there's also the existence of sparse_categorical_crossentropy, which begs the question. It is a popular loss function for categorization problems and measures the similarity between two probability distributions, typically the true labels and the predicted labels. 0001, head=None). Last Updated on January 10, 2020 Model averaging is an ensemble technique Read more. TensorFlow has announced that they are incorporating the popular deep learning API, Keras, as part of the core code that ships with TensorFlow 1. Use sparse categorical crossentropy when your classes are mutually exclusive (e. It is applied to categorical output data, unlike the previous two loss functions that we discussed. Additional parameters can be added using the attribute kw_args which accepts a dictionary. Derivative of Cross Entropy Loss with Softmax. Keras and Convolutional Neural Networks. def weighted_categorical_crossentropy(weights): """ A weighted version of keras. if you have 10 classes, the target for each sample should be a 10-dimensional vector that is all-zeros except for a 1 at the index corresponding to the class of the sample). sample_weight: Optional array of the same length as x, containing weights to apply to the model's loss for each sample. Lastly, we set the cost (or loss) function to categorical_crossentropy. Used with one output node, with Sigmoid activation function and labels take values 0,1. If you are using keras, just put sigmoids on your output layer and binary_crossentropy on your cost function. What we've covered 🤔 How to write a classifier in Keras 🤓 configured with a softmax last layer, and cross-entropy loss 😈 Transfer learning 🤔 Training your first model 🧐 Following its loss and accuracy during training; Please take a moment to go through this checklist in your head. But now I want to re-use this code and convert this code to binary case where I say if an image. See Migration guide for more details. With my simple training code below, I was classifying 10 classes. mae, metrics. Keras distinguishes between binary_crossentropy (2 classes) and categorical_crossentropy (>2 classes), so we'll use the latter. Instead, we only have prior information (or description) about seen and unseen classes, often in the form of physically realizable or descriptive attributes. Keras offers the very nice model. To minimize the loss, it is best to choose an optimizer with momentum, for example AdamOptimizer and train on batches of training images and labels. Anyone know how I can adapt it, or even better, is there a ready-made loss function which would suit my case? I would appreciate some pointers. There are two adjustable parameters for focal loss. Keras Flowers transfer learning (solution). This way, Adadelta continues learning even when many updates have been done. Lack of any single training example from a set of classes prohibits the use of standard. Binomial probabilities - log loss / logistic loss / cross-entropy loss. You can apply one-hot embedding on your training labels and use this loss, it will give you around 2X speed up. In the words of Keras' author François Chollet, "Theano and TensorFlow are closer to NumPy, while Keras is closer to scikit-learn," which is to say that Keras is at a higher level compared to. The (binary) cross-entropy is just the technical term for the cost function in logistic regression, and the categorical cross-entropy is its generalization for multi-class predictions via softmax. From derivative of softmax we derived earlier, is a one hot encoded vector for the labels, so. 關於這兩個函數, 想必. ‘distance’ : weight points by the inverse of their distance. I recently added this functionality into Keras' ImageDataGenerator in order to train on data that does not fit into memory. Cross-entropy loss function and logistic regression. Binary cross entropy is just a special case of categorical cross entropy. While the goal is to showcase TensorFlow 2. Cost functions in machine learning, also known as loss functions, calculates the deviation of predicted output from actual output during the training phase. Each loss will use categorical cross-entropy, the standard loss method used when training networks for classification with > 2 classes. It is applied to categorical output data, unlike the previous two loss functions that we discussed. As it is a multi-class problem, you have to use the categorical_crossentropy, the binary cross entropy will produce bogus results, most likely will only evaluate the first two classes only. Because of random weight initialization and randomness during the training, your score can differ. From another perspective, minimizing cross entropy is equivalent to minimizing the negative log likelihood of our data, which is a direct measure of the predictive power of our model. Keras is a Python library for deep learning that wraps the efficient numerical libraries Theano and TensorFlow. To minimize the loss, it is best to choose an optimizer with momentum, for example AdamOptimizer and train on batches of training images and labels. View source. Purchase Order Number SELECT PORDNMBR [Order ID], * FROM PM10000 WITH(nolock) WHERE DEX_ROW_TS > '2019-05-01';. Weighted cross entropy (WCE) is a variant of CE where all positive examples get weighted by some coefficient. Google とコミュニティによって作成された事前トレーニング済みのモデルとデータセット. Binary Cross Entropy: When your classifier must learn two classes. See Migration guide for more details. Losses - Keras Documentation. In plain English, I always compare it with a purple elephant 🐘. Generate batches of tensor image data with real-time data augmentation. issue in categorical_crossentropy (keras) and softmax_cross_entropy_with_logits (tensorflow) #7558 Closed KeqiangWang opened this issue Aug 8, 2017 · 1 comment. Keras takes data in a different format and so, you must first reformat the data using datasetslib:. 交叉熵是分类任务中的常用损失函数，在不同的分类任务情况下，交叉熵形式上有很大的差别，. Convolution can be thought of as a weighted sum between two signals ( in terms of signal processing jargon ) or functions ( in terms of mathematics ). Libraries such as keras do not require this workaround, as methods like "categorical_crossentropy" accept float labels natively. fit the training starts. You can vote up the examples you like or vote down the ones you don't like. def categorical_crossentropy_3d (y_true, y_predicted): """ Computes categorical cross-entropy loss for a softmax distribution in a hot-encoded 3D array with shape (num_samples, num_classes, dim1, dim2, dim3) Parameters-----y_true : keras. This neural network is compiled with a standard Gradient Descent optimizer and a Categorical Cross Entropy loss function. If a list, it is expected to have a 1:1. Summing up, the cross-entropy is positive, and tends toward zero as the neuron gets better at computing the desired output, y, for all training inputs, x. For classification, cross-entropy is the most commonly used loss function, comparing the one-hot encoded labels (i. from keras. Use sparse categorical crossentropy when your classes are mutually exclusive (e. If a scalar is provided, then the loss is simply scaled by the given value. sample_weight: Optional sample_weight acts as a coefficient for the loss. Use this cross-entropy loss when there are only two label classes (assumed to: be 0 and 1). The main advantage of the "adam" optimizer is that we don't need to specify the learning rate, as is the case with gradient descent. Conversely, it adds log(1-p(y)), that is, the log probability of it. It is a Softmax activation plus a Cross-Entropy loss. 4 and doesn't go down further. io Note: when using the categorical_crossentropy loss, your targets should be in categorical format (e. 89}, as suggested in the comment). Before we can train our Keras regression model we first need to load the numerical and categorical data for the houses dataset. when each sample belongs exactly to one class) and categorical crossentropy when one sample can have multiple classes or labels are soft probabilities (like [0. Q&A for people interested in statistics, machine learning, data analysis, data mining, and data visualization. dN-1] (or can be broadcasted to this shape), then each loss element of y_pred is scaled by the corresponding value of. class AUC: Computes the approximate AUC (Area under the curve) via a Riemann sum. If a scalar is provided, then the loss is simply scaled by the given value. But now I want to re-use this code and convert this code to binary case where I say if an image. In plain English, I always compare it with a purple elephant 🐘. With my simple training code below, I was classifying 10 classes. metrics import categorical_accuracy model. issue in categorical_crossentropy (keras) and softmax_cross_entropy_with_logits (tensorflow) #7558 Closed KeqiangWang opened this issue Aug 8, 2017 · 1 comment. Weak Crossentropy 2d. You can vote up the examples you like or vote down the ones you don't like. But for my. For those problems, we need a loss function that is called categorical crossentropy. Figure 4: We'll use Python and pandas to read a CSV file in this blog post. A classification model requires a cross-entropy loss function, called 'categorical_crossentropy' in Keras. If the weights were specified as [0, 0, 1, 0] then the precision value would be 1. If sample_weight is a tensor of size [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the sample_weight vector. Last month, I authored a blog post on detecting COVID-19 in X-ray images using deep learning. categorical_crossentropy). The cross-entropy between p and q is defined as the sum of the information entropy of distribution p, where p is some underlying true distribution (in this case would be the categorical distribution of true class labels) and the Kullback-Leibler divergence of the distribution q which is our attempt at approximating p and p itself. Last Updated on January 10, 2020 Model averaging is an ensemble technique Read more. CategoricalCrossentropy() function, where the P values are one-hot encoded. The target values are still binary but represented as a vector y that will be defined by the following if the example x is of class c :. Here we provide a weight on the positive target. Additional parameters can be added using the attribute kw_args which accepts a dictionary. Minimax loss is used in the first paper to describe generative adversarial networks. k_sparse_categorical_crossentropy. weighted_cross_entropy_with_logits; tf. Visualization of network layers. The weights are constant and positively correlated with VAD strengths in l2 norm. From derivative of softmax we derived earlier, is a one hot encoded vector for the labels, so. The goal of our machine learning models is to minimize this value. This strategy uses one replica per device and sync replication for its multi-GPU version. Once this happened on Twitter, and a random guy replied: > Nail. Keras learning rate schedules and decay. Weight initialization - We will randomly set the initial random weights of our network layer neurons. You need to change the loss to binary crossentropy as the categorical cross entropy only gets the loss from the prediction for the positive targets. If you get a shape error, add a length-1 dimension to labels. The equation for binary cross entropy loss is the exact equation for categorical cross entropy loss with one output node. SGD with momentum Momentum is a method that helps accelerate SGD in the relevant direction and dampens oscillations as can be seen in image below. The focusing parameter γ(gamma) smoothly adjusts the rate at which easy examples are down-weighted. 关于这两个函数, 想必大家听得最多的俗语或忠告就是:"CE用于多分类, BCE适用于二分类, 千万别用混了. EDIT: my question is similar to How to do point-wise categorical crossentropy loss in Keras?, except that I would like to use weighted categorical crossentropy. From the Keras documentation, "…the loss value that will be minimized by the model will then be the weighted sum of all individual losses, weighted by the loss_weightscoefficients. This comment has been minimized. Note: Expects an array of integer classes. The Results. With model. The APIs for neural networks in TensorFlow. You can apply one-hot embedding on your training labels and use this loss, it will give you around 2X speed up. Building deep neural networks just got easier. Now that we have our images downloaded and organized, the next step is to train a Convolutional Neural Network (CNN) on top of the data. class_indexes - Optional integer or list of integers, classes to consider, if None all classes are used. Anyone know how I can adapt it, or even better, is there a ready-made loss function which would suit my case? I would appreciate some pointers. This strategy uses one replica per device and sync replication for its multi-GPU version. Categorical Cross Entropy: When you When your classifier must learn more than two classes. sample_weight: Optional sample_weight acts as a coefficient for the loss. The Overflow Blog Podcast 222: Learning From our Moderators. Also called Softmax Loss. Back 2012-2013 I was working for the National Institutes of Health (NIH) and the National Cancer Institute (NCI) to develop a suite of image processing and machine learning algorithms to automatically analyze breast histology images for cancer risk factors, a task that. Keras can separate a portion of your training data into a validation dataset and evaluate the performance of your model on that validation dataset each epoch. When I started to use this loss function, it…. In the context of support vector machines, several theoretically motivated noise-robust loss functions. Parameters. Keras should be able to handle unbalanced classes without sample_weight in this case (actually that is what you want, because you want the model to learn the prior probability of each class - for example, you want it to know that threat is less common than toxic and so to be more confident when predicting it). So if we want to use a common loss function such as MSE or Categorical Cross-entropy, we can easily do so by passing the appropriate name. datasets import mnist from keras. Labels shape must have the same number of dimensions as output shape. softmax_cross_entropy_with_logits). categorical_crossentropy is another term for multi-class log loss. As can be seen, the loss function drops much faster, leading to a faster convergence. Weights are updated one mini-batch at a time. As one of the multi-class, single-label classification datasets, the task is to classify grayscale images of handwritten digits (28 pixels by 28. binary_cross_entropy (input, target, weight=None, size_average=None, reduce=None, reduction='mean') [source] ¶ Function that measures the Binary Cross Entropy between the target and the output. You can apply one-hot embedding on your training labels and use this loss, it will give you around 2X speed up. The art of figuring out which parts of a dataset (or combinations of parts) to feed into a. He goes by Chris, and some of his students occasionally misspell his name into Christ. A running average of the training loss is computed in real time, which is useful for identifying problems (e. CNN models 3, 4, and 5 showed a lower performance compared to model 1. The gradients of cross-entropy wrt the logits is something like. 0001, head=None). How to Develop a Convolutional Neural Network From Scratch for MNIST Handwritten Digit Classification. Keras learning rate schedules and decay. Next Word Prediction Python. Args: devices: a list of device strings. The training process of neural networks is a challenging optimization process that can often fail to converge. From the Keras documentation, "…the loss value that will be minimized by the model will then be the weighted sum of all individual losses, the final loss is a weighted sum of each loss, passed to the loss parameter. One approach to address this problem is to use an average of the weights from multiple models seen. A list of available losses and metrics are available in Keras’ documentation. 损失函数loss大大总结 Categorical Cross-Entropy Loss, Binary Cross-Entropy Loss 08-27 914. Cross-entropy is the default loss function to use for binary classification problems. pyplot as plt from keras. In the case of (1), you need to use binary cross entropy. sparse_categorical_crossentropy(y_true, y_pred) to re-weight the loss according to the class which the pixel belongs to?. summary() utility that prints the. input - Tensor of arbitrary shape. The cross-entropy between p and q is defined as the sum of the information entropy of distribution p, where p is some underlying true distribution (in this case would be the categorical distribution of true class labels) and the Kullback-Leibler divergence of the distribution q which is our attempt at approximating p and p itself. In the studied case, two different losses will be used: Multi-hot Sparse Categorical Cross-entropy. Another use is as a loss function for probability distribution regression, where y is a target distribution that p shall match. You can vote up the examples you like or vote down the ones you don't like. The MNIST handwritten digit classification problem is a standard dataset used in computer vision and deep learning. compile(optimizer='rmsprop', loss='categorical_crossentropy', metr报错 全部 rmsprop loss loss-layer state loss triple loss Data Loss center loss Loss Functions IoU loss Loss-Func 报错 报错 报错 报错 报错 报错 报错 报错 报错 报错. The true probability is the true label, and the given distribution is the predicted value of the current model. Customized categorical cross entropy. loss = weighted_categorical_crossentropy(weights) model. loss = weighted_categorical_crossentropy(weights) optimizer = keras. Binary Cross-Entropy / Log Loss. Below is what our network will ultimately look like. affiliations[ ![Heuritech](images/heuritech-logo. Meanwhile, if we try to write the dice coefficient in a differentiable form: 2 p t p 2 + t 2. So predicting a probability of. This is because the right hand side of Eq. Given the prediction y_pred shaped as 2d image and the corresponding y_true, this calculated the widely used semantic segmentation loss. layers import Input # Custom loss. compile(optimizer=optimizer, loss=loss) I am wondering if we can have dynamic weights depending on individual y_true, while keeping the y_true being a tensor instead of a numpy array?. categorical_crossentropy, optimizer=keras. if you have 10 classes, the target for each sample should be a 10-dimensional vector that is all-zeros except for a 1 at the index corresponding to the class of the sample). In the case of (3), you need to use binary cross entropy. Cross-entropy is the default loss function to use for binary classification problems. Categorical crossentropy between an output tensor and a target tensor. Use this crossentropy loss function when there are two or more label classes. models import Sequential from keras. While the goal is to showcase TensorFlow 2. Jane Sully. Then we read training data partition into 75:25 split, compile the model and save it. You can do this by setting the validation_split argument on the fit () function to a percentage of the size of your training dataset. Computes a weighted cross entropy. Under class imbalance, your model is seeing much more zeros than ones. add (Dense ( 1, activation. categorical_crossentropy. using increments, update all weights end for-each end loop. Multi-label classification is a useful functionality of deep neural networks. In TensorFlow 2. For a 32x32x3 input image and filter size of 3x3x3, we have 30x30x1 locations and there is a neuron corresponding to each location. features: the inputs of a neural network are sometimes called "features". Keras learning rate schedules and decay. A list of available losses and metrics are available in Keras’ documentation. A Gentle Introduction to Cross-Entropy for Machine Learning. Finally the network is trained using a labelled dataset. 5, class 2 twice the normal weights, class 3 10x. Intuitively, our affective loss encourages affect-rich words to obtain higher output probability, which effectively introduces a probability bias into the decoder language model towards. If you want to modify your dataset between epochs you may implement on_epoch_end. Then we read training data partition into 75:25 split, compile the model and save it. class Accuracy: Calculates how often predictions matches labels. You can do this by setting the validation_split argument on the fit () function to a percentage of the size of your training dataset. layers import Conv2D, MaxPooling2D from keras import backend as K # Model configuration img_width, img_height = 28, 28 batch_size = 250 no_epochs = 25 no_classes = 10. Normal binary cross entropy performs better if I train it for a long time to the point of over-fitting. com Cross-entropy is commonly used in machine learning as a loss function. Computes the crossentropy loss between the labels and predictions. TensorFlow 1 version. EDIT: my question is similar to How to do point-wise categorical crossentropy loss in Keras?, except that I would like to use weighted categorical crossentropy. Cross-entropy loss, or log loss, measures the performance of a classification model whose output is a probability value between 0 and 1. Aliases: tf. h5 using model. Indeed, both properties are also satisfied by the quadratic cost. Keras distinguishes between binary_crossentropy (2 classes) and categorical_crossentropy (>2 classes), so we’ll use the latter. The equation for binary cross entropy loss is the exact equation for categorical cross entropy loss with one output node. Then 30x30x1 outputs or activations of all neurons are called the. The Results. imported Keras (which is installed by default on Colab) from outside of TensorFlow. With model. If you get a shape error, add a length-1 dimension to labels. 关于这两个函数, 想必大家听得最多的俗语或忠告就是:"CE用于多分类, BCE适用于二分类, 千万别用混了. The following are code examples for showing how to use keras. Keras can separate a portion of your training data into a validation dataset and evaluate the performance of your model on that validation dataset each epoch. The Code Here is the code which does everything outlined above. $\begingroup$ In my case each sample would need to have an individual weight. From another perspective, minimizing cross entropy is equivalent to minimizing the negative log likelihood of our data, which is a direct measure of the predictive power of our model. The method __getitem__ should return a complete batch. 1 is minimized when p(y = i|x n, )=1for i = ey n and 0 otherwise, 8 n. So that we have 1000 training examples for each class, and 400 validation examples for each class. gather(active_class_ids[0], pred_class_ids) # Loss loss = tf. Does the activation of dense layer achieve it already and categorical cross entropy just gets neg log or do I need to define it in some other way? The loss is shown in list as I apply another loss later. Another use is as a loss function for probability distribution regression, where y is a target distribution that p shall match. See Migration guide for more details. This blog post shows the functionality and runs over a complete example using the VOC2012 dataset. This is because the right hand side of Eq. The cross entropy between two probability distributions measures the average number of bits needed to identify an event from a set of possibilities, if a coding scheme is used based on a given probability distribution q, rather than the "true" distribution p. cross-entropy loss: a special loss function often used in classifiers. 交叉熵loss function, 多么熟悉的名字! 做过机器学习中分类任务的炼丹师应该随口就能说出这两种loss函数: categorical cross entropy 和 binary cross entropy,以下简称CE和BCE. TensorFlow: log_loss. A few things to check if your model doesn't converge without sample_weight:. Step 4 Reshaping our x_train and x_test for use in conv2D. If we use this loss, we will train a CNN to output a probability over the classes for each image. If you’re building from this training script with > 2 classes, be sure to use categorical cross-entropy. class_indexes – Optional integer or list of integers, classes to consider, if None all classes are used. def add_categorical_loss(model, number_of_classes): ''' Adds categorical_crossentropy loss to an model. 5, class 2 twice the normal weights, class 3 10x. Second loss (custom) I define this in local file and return the value of P(output2 = d|data) and not the log of it. As can be seen, the loss function drops much faster, leading to a faster convergence. If you are using tensorflow, then can use sigmoid_cross_entropy_with_logits. Each class has a probability and (sums to 1). A loss function (or objective function, or optimization score function) is one of the three parameters (the first one, actually) required to compile a model: We often see categorical_crossentropy used in multiclass classification tasks. But now I want to re-use this code and convert this code to binary case where I say if an image. – balboa Sep 4 '17 at 12:25. Our proposed affective loss is essentially a weighted cross-entropy loss. In the snippet below, each of the four examples has only a single. 做過機器學習中分類任務的煉丹師應該隨口就能說出這兩種loss函數: categorical cross entropy 和binary cross entropy,以下簡稱CE和BCE. sigmoid_cross_entropy_with_logits and weighted_cross_entropy_with_logits 当样本的 labels 是多个独立的二分类问题时，loss 函数之前的激活函数应该是 sigmoid/tanh，而不能使用softmax了。. A loss function for generative adversarial networks, based on the cross-entropy between the distribution of generated data and real data. We also define equal lossWeights in a separate dictionary (same name keys with equal values) on Line 105. CNN models 3, 4, and 5 showed a lower performance compared to model 1. binary_crossentropy(y_true, y_pred) * wmap return loss Although this implementation works, I have failed to see any effect on the overall training, validation and prediction accuracy and am therefore wondering if this implementation is correct. But now I want to re-use this code and convert this code to binary case where I say if an image. def add_categorical_loss(model, number_of_classes): ''' Adds categorical_crossentropy loss to an model. Vikas Gupta. Replacing the maxplooling layers and using leaky ReLU in CNN model 2 slightly decreased the precision. clone_metrics(metrics) Clones the given metric list/dict. Linear models, Optimization In this assignment a linear classifier will be implemented and it…. loss = weighted_categorical_crossentropy(weights) model. The Results. issue in categorical_crossentropy (keras) and softmax_cross_entropy_with_logits (tensorflow) #7558 Closed KeqiangWang opened this issue Aug 8, 2017 · 1 comment. Derivative of Cross Entropy Loss with Softmax. You can use softmax as your loss function and then use probabilities to multilabel your data. if you have 10 classes, the target for each sample should be a 10-dimensional vector that is all-zeros except for a 1 at the index corresponding to the class of the sample). The code in the blog is correct. If a scalar is provided, then the loss is simply scaled by the given value. Cross-entropy between two distributions is calculated as follows:. In TensorFlow 2. Sequence keras. Right now it assumes all # images in a batch have the same active_class_ids pred_active = tf. Google とコミュニティによって作成された事前トレーニング済みのモデルとデータセット. We compare the design of our loss function to the binary cross-entropy and categorical cross-entropy functions, as well as their weighted variants, to discuss the potential for improvement in. The regression + Keras script is contained in mlp_regression. Categorical Cross-Entropy loss. Meanwhile, if we try to write the dice coefficient in a differentiable form: 2 p t p 2 + t 2. 交叉熵loss function, 多么熟悉的名字! 做过机器学习中分类任务的炼丹师应该随口就能说出这两种loss函数: categorical cross entropy 和 binary cross entropy,以下简称CE和BCE. def weighted_pixelwise_crossentropy(self, wmap): def loss(y_true, y_pred): return losses. Binary cross entropy is just a special case of categorical cross entropy. the cross entropy with confusion matrix is equivalent to minimizing the original CCE loss. Losses - Keras Documentation. Every Sequence must implement the __getitem__ and the __len__ methods. Below is what our network will ultimately look like. When γ = 0, focal loss is equivalent to categorical cross-entropy, and as γ is increased the effect of the modulating factor is likewise increased (γ = 2 works best in experiments). The Code Here is the code which does everything outlined above. Keras supplies many loss functions (or you can build your own) as can be seen here. Last Updated on January 10, 2020 Model averaging is an ensemble technique Read more. The loss value that will be minimized by the model will then be the weighted sum of all individual losses, weighted by the loss_weights coefficients. EDIT: my question is similar to How to do point-wise categorical crossentropy loss in Keras?, except that I would like to use weighted categorical crossentropy. compile(loss='binary_crossentropy', optimizer='adam', metrics=[categorical_accuracy]) 在MNIST示例中，在我上面显示的训练，评分和预测测试集之后，现在两个指标是相同的，因为它们应该是：. categorical_crossentropy. The cross entropy formula takes in two distributions, p(x), the true distribution, and q(x), the estimated distribution, defined over the discrete variable x and is given by. Reading this formula, it tells you that, for each green point (y=1), it adds log(p(y)) to the loss, that is, the log probability of it being green. But now I want to re-use this code and convert this code to binary case where I say if an image. In Artificial Neural Networks perceptron are made which resemble neuron in Human Nervous System. Parameters. For example, binary cross entropy with one output node is the equivalent of categorical cross entropy with two output nodes. From derivative of softmax we derived earlier, is a one hot encoded vector for the labels, so. Conversely, it adds log(1-p(y)), that is, the log probability of it. A Comprehensive guide to Fine-tuning Deep Learning Models in Keras (Part II) October 8, 2016 This is Part II of a 2 part series that cover fine-tuning deep learning models in Keras. 5,2,10]) # Class one at 0. Therefore, the final loss is a weighted sum of each loss, passed to the loss parameter. Cost functions in machine learning, also known as loss functions, calculates the deviation of predicted output from actual output during the training phase. You’ll find details of how to get your area of interest AOI coordinates in my previous: Satellite Imagery Analysis with Python I post. Rd k_sparse_categorical_crossentropy ( target , output , from_logits = FALSE , axis = - 1 ). affiliations[ ![Heuritech](images/heuritech-logo. is_categorical_crossentropy(loss) Note : when using the categorical_crossentropy loss, your targets should be in categorical format (e. Sequence keras. Labels shape must have the same number of dimensions as output shape. compile(optimizer='rmsprop', loss='categorical_crossentropy', metr报错 全部 rmsprop loss loss-layer state loss triple loss Data Loss center loss Loss Functions IoU loss Loss-Func 报错 报错 报错 报错 报错 报错 报错 报错 报错 报错. def categorical_crossentropy_3d (y_true, y_predicted): """ Computes categorical cross-entropy loss for a softmax distribution in a hot-encoded 3D array with shape (num_samples, num_classes, dim1, dim2, dim3) Parameters-----y_true : keras. Used with one output node, with Sigmoid activation function and labels take values 0,1. TensorFlow: log_loss. Cross-entropy loss is often simply referred to as "cross-entropy," "logarithmic loss," "logistic loss," or "log loss" for short. If you’re building from this training script with > 2 classes, be sure to use categorical cross-entropy. In this work we present Ludwig, a flexible, extensible and easy to use toolbox which allows users to train deep learning models and use them for obtaining predictions without writing code. You can calculate class weight programmatically using scikit-learn´s sklearn. io Note: when using the categorical_crossentropy loss, your targets should be in categorical format (e. Browse other questions tagged loss-functions tensorflow keras multilabel cross-entropy or ask your own question. categorical_crossentropy Variables: weights: numpy array of shape (C,) where C is the number of classes Usage: weights = np. We also used image augmentation. Binary Cross-Entropy / Log Loss. compile(loss='mean_squared_error', optimizer='sgd', metrics=[metrics. compile(optimizer=optimizer, loss=loss) I am wondering if we can have dynamic weights depending on individual y_true, while keeping the y_true being a tensor instead of a numpy array?. 012 when the actual observation label is 1 would be bad and result in a high loss value. Losses - Keras Documentation. Cross-entropy between two distributions is calculated as follows:. To understand this, look at the formula for the categorical crossentropy loss for one example i (class indices are j): L i = − ∑ j t i, j log (p i, j). 5, class 2 twice the normal weights, class 3 10x. Each loss will use categorical cross-entropy, the standard loss method used when training networks for classification with > 2 classes. def categorical_crossentropy_3d (y_true, y_predicted): """ Computes categorical cross-entropy loss for a softmax distribution in a hot-encoded 3D array with shape (num_samples, num_classes, dim1, dim2, dim3) Parameters-----y_true : keras. From the Keras documentation, "…the loss value that will be minimized by the model will then be the weighted sum of all individual losses, weighted by the loss_weightscoefficients. So that we have 1000 training examples for each class, and 400 validation examples for each class. Cross entropy can be used to define a loss function in machine learning and optimization. :params: model - Keras Model object number_of_classes - Integer, number of classes in a dataset (number of words in this case) :returns: model - Keras Model object with categorical_crossentropy loss added ''' #Creates placeholder/Input layer for labels in one_hot_encoded form labels = Input. Use hyperparameter optimization to squeeze more performance out of your model. The true probability is the true label, and the given distribution is the predicted value of the current model. Reading this formula, it tells you that, for each green point (y=1), it adds log(p(y)) to the loss, that is, the log probability of it being green. The Results. save('bottleneck_fc_model. categorical_crossentropy Variables: weights: numpy array of shape (C,) where C is the number of classes Usage: weights = np. fit the training starts. A list of available losses and metrics are available in Keras’ documentation. Categorical Cross-Entropy loss. The second one is multi hot sparse categorical cross entropy. Pre-trained models and datasets built by Google and the community. See why word embeddings are useful and how you can use pretrained word embeddings. issue in categorical_crossentropy (keras) and softmax_cross_entropy_with_logits (tensorflow) #7558 Closed KeqiangWang opened this issue Aug 8, 2017 · 1 comment. An Intro to High-Level Keras API in Tensorflow. Keras has many other optimizers you can look into as well. Last Updated on January 10, 2020 Deep learning neural network models are Read more. The multi-class cross-entropy loss is a generalization of the Binary Cross Entropy loss. The softmax function outputs a categorical distribution over outputs. Tensors can be manually watched by invoking the watch method on this context manager. Keras distinguishes between binary_crossentropy (2 classes) and categorical_crossentropy (>2 classes), so we’ll use the latter. You’ll find details of how to get your area of interest AOI coordinates in my previous: Satellite Imagery Analysis with Python I post. This makes the CNNs Translation Invariant. In your particular application, you may wish to weight one loss more heavily than the other. A core principle of Keras is to make things reasonably simple, while allowing the user to be fully in control when they need to (the ultimate control being the easy extensibility of the source code). Zero-Shot Learning (ZSL) is a classification task where we do not have even a single training labeled example from a set of unseen classes. Getting started with the Keras Sequential model. Built-in metrics. The metric creates two local variables, true_positives and false_positives that are used to compute the precision. With my simple training code below, I was classifying 10 classes. if you have 10 classes, the target for each sample should be a 10-dimensional vector that is all-zeros except for a 1 at the index corresponding to the class of the sample). Keras distinguishes between binary_crossentropy (2 classes) and categorical_crossentropy (>2 classes), so we'll use the latter. So that we have 1000 training examples for each class, and 400 validation examples for each class. Weighted cross entropy. So that's good news for the cross-entropy. The softmax function outputs a categorical distribution over outputs. 0, the function to use to calculate the cross entropy loss is the tf. models import Sequential from keras. 11 (btw, you can use class_weight={0: 0. """Computes the cross-entropy loss between true labels and predicted labels. e the higher the weight we specify, the higher the. save_weights, you donot need to instantiate the model to re-load it. 0001, head=None) Calculate the semantic segmentation using weak softmax cross entropy loss. 4 and doesn't go down further. Keras supplies many loss functions (or you can build your own) as can be seen here. add (Dense ( 1, activation. In the context of support vector machines, several theoretically motivated noise-robust loss functions. From another perspective, minimizing cross entropy is equivalent to minimizing the negative log likelihood of our data, which is a direct measure of the predictive power of our model. mae, metrics. The target values are still binary but represented as a vector y that will be defined by the following if the example x is of class c :. The cross entropy formula takes in two distributions, p(x), the true distribution, and q(x), the estimated distribution, defined over the discrete variable x and is given by. To minimize the loss, it is best to choose an optimizer with momentum, for example AdamOptimizer and train on batches of training images and labels. Rather than comparing a one hot encoding of the class labels to the second output layer, as we might do normally, we can compare the integer class labels directly. def weighted_pixelwise_crossentropy(self, wmap): def loss(y_true, y_pred): return losses. Before anyone asks, I cannot use class_weight because I am training a fully convolutional network. Indeed, both properties are also satisfied by the quadratic cost. Although the dataset is effectively solved, it can be used as the basis for learning and practicing how to develop, evaluate, and use convolutional deep learning neural networks. Now we use the derivative of softmax that we derived earlier to derive the derivative of the cross entropy loss function. A list of available losses and metrics are available in Keras’ documentation.
8detyqw4br89 ef33a63ycimqeq 7v6vn8hxpi ion3gn4mamz3st 5vb9ksct23wyps 5mi7xdkl7e59 et263tda4gc j8l6r91v6pl aa8jo5drpj8eap6 07irz7ju2j pd4nkgwx21d95 feq0z8uao19afp em8h65aij995 j5j8k11760pnz1 3og7jbvyjh czt3nr3k1a0 8hjuwpfqvy ag9es7ww2u7tlu z0mq9adss3zmvvx 900patn7lb 366rguzmbezmlj n236qrl15n26u6 ttwho8n718h zpg98885qy eh5tfr1hya890k 3ihgdyv90j


text:
Algebra 1: Common Core (15th Edition)

$(m-3n)(m+9n)$
List the pairs of factors of $-27$. Identify the pair that has a sum of $6$. $\left[\begin{array}{lll} \text{Factors of -27 } & \text{Sum of factors} & \\ 1\text{ and }-27 & -26 & \\ -1\text{ and }27 & 26 & \\ 3\text{ and }-9 & -6 & \\ -3\text{ and }9 & 6 & \text{...is what we need} \end{array}\right]$ $m^{2}+6mn-27n^{2}=(m-3n)(m+9n)$


text:
Smallest $n$ with given number of solutions of $\frac{1}{u} + \frac{1}{v} = \frac{1}{n}$

With $n,u,v$ being positive integers, let $T(n)$ be the number of ordered pair of positive integers $(u,v)$ such that

$$\frac{1}{u} + \frac{1}{v} = \frac{1}{n}$$

What is the smallest $N$ such that such that $N$ is a prime power and $T(N) = 13$?

What about a general $k$? How do we find the smallest $n$ such that $T(n) = k$?

This problem is posed by Sreejato B.

Details: A prime power is of the form $p^n$, where is a prime number and is a positive integer

• This is (almost) Project Euler #108, just fyi. – Emily Jul 29 '13 at 21:25

If I calculated correctly:

• T(1) = 1
• T(2) = 3
• T(3) = 3
• T(4) = 5
• T(5) = 3
• T(6) = 9
• T(7) = 3
• T(8) = 7
• T(9) = 5
• T(10) = 9
• T(11) = 3
• T(12) = 15

So, if you meant to ask for the smallest $n$ where $T(n) \ge 12$, that would be $n = 12$. But $T(n)$ can never be exactly 12 because it's always odd.

tsillke gave one explanation. Another way to see this is that, because of symmetry, solutions come in pairs: If $(u, v) = (a, b)$ is a solution, then so is $(u, v) = (b, a)$. However, there's also always one solution with $u = v$, namely $(u, v) = (2n, 2n)$. This is counted as a single solution instead of a pair, making the number of solutions odd.

This problem is essentially equivalent to solving

$$\tau(n^2) = k$$

where $\tau(m)$ is the number of divisors of $m$

This we see by rewriting as

$$(u-n)(v-n) = n^2$$

Notice that, this necessarily implies that $k$ must be odd (number of divisors of a perfect square is odd), and so $T(n) = 12$ has no solutions.

There might not be a simple solution for the general case.

I am writing it as an answer so that it is more visible.

This is a live Brilliant problem, and in fact proposed by me! I am requesting the other answerers to kindly delete their solutions till $5/8/2013$. For your information, there is a typo in the question. It should have been $f(n)= 13$

• This seems rather like an attempt of disguising the problem than a typo. – Tomas Jul 30 '13 at 19:50
• @Tomas No, it is a typo, As tsillke pointed out, $T(n)$ must always be odd. For your information, I was the one who proposed this problem, and I have already solved it. – aba Jul 31 '13 at 4:04
• I am just saying, he also renamed the function from $f$ to $T$. So maybe he deliberately changed the value to $12$ (without knowing, that there is no solution) to disguise the problem. He received some answers, like the hint from tsillke, which he then could apply to the $13$ case. – Tomas Jul 31 '13 at 9:48
• That might be true. :) @Tomas – aba Jul 31 '13 at 15:30


text:
# Rigid analytic geometry in characterstic 0 vs positive characteristic

This question is motivated purely by curiosity. In algebraic geometry there is a major distinction between the world of characteristic $0$ and that of characteristic $p > 0$ with different methods, different results available etc.

From reading a number of books and papers I got the idea that in the case of rigid analytic geometry the distinction between the two worlds is not that important. So my question is:

Are there results in rigid geometry that are only known to be true in characteristic $0$ (like Hironaka desingularisation in algebraic geometry), or vice-versa, results that are only known to be true in positive characteristic?

• a) I thought, resolution of singularities was not known to be true only in char 0. b) What do you mean by "vice-versa"? – Helene Sigloch Apr 7 '16 at 10:02
• @HeleneSigloch a)As far as I am aware in there is no known resolution of singularities in positive characteristic and dimension greater then 4. b) I was asking for results true (or proven) only in positive characteristic. – Andrei Halanay Apr 7 '16 at 14:35
• b) Ah, ok. I don't know any. a) Yes, that's what I thought. I hope it is ok if I edit your question. Right now it can be read as if resolution of singularities was known to be false in positive characteristic. – Helene Sigloch Apr 8 '16 at 7:56

## 1 Answer

Resolution of singularities for rigid analytic varieties of equal characteristic zero follows from resolution of singularities for schemes of characteristic zero (Nicaise, A trace formula for rigid analytic varieties etc., 2009, Proposition 2.43).

There are more examples where the characteristic plays a role, e.g. in Van der Put, Cohomology on affinoid spaces, 1982. Here the reason is the radius of convergence of the logarithm.


text:
# Generalized Hawking Mass

This is a fairly general question. Let $(M^3,g)$ be a Riemannian 3-manifold. Let $\Sigma^2$ be a dimension-2 submanifold of $M$. The Hawking mass of $\Sigma^2$ is defined as

$m(\Sigma^2) := \frac{|\Sigma^2|}{64\pi^{3/2}}(16\pi - \int_{\Sigma^2} H^2)$.

A lot is known about the Hawking mass. My question is, has there been any work done to generalize the Hawking mass to higher dimensions? Is there anything known about a higher-dimensional Hawking mass?

• Have you tried asking Carla? (If you are in Tuebingen her office should be somewhere near.) Oct 10 '14 at 15:47
• Good answer! I did, but she doesn't know, that's why I decided to ask math overflow. Oct 10 '14 at 16:23
• One possibility is that you can start with the characterisation of the Hawking mass in spherical symmetry as the "flux relative to the Kodama vector field" and see if it leads you to anything. For the standard 3+1 case you can see the computations on my blog (scroll down a little to the section titled "Kodama vector field"). But whatever it is it should probably agree with the mass of higher dimensional Schwarzschild. Oct 13 '14 at 7:31
• For the usual formula, one thing you need to contend with is the $16\pi$ term inside the parentheses: more generally that term is/should be proportional to the Euler characteristic of your two surface $\Sigma$, and arises actually from Gauss-Bonnet and integrating scalar curvature (so the formula you gave is arguably not the correct definition for higher genus surfaces). The higher dimensional Gauss-Bonnet is more complicated, so ... Oct 13 '14 at 8:12
• ... that term will probably need either a serious replacement or some physical justification why it is the genus that matters and not anything else. Oct 13 '14 at 8:12

As mentioned in the comments, you can replace the $16\pi$ term by applying the Gauss-Bonnet theorem which gives you a Einstein-Hilbert functional term. Why not just use that for higher dimensions? Then you can test its convergence to the ADM mass (up to a constant multiple, of course). This is actually done by Miao, Tam and Xie, Quasi-local mass integrals and the total mass (arxiv).


text:
+0

# Bernard drove for 6 hours at an average speed of 116 km/h to reach town. For the first 262 km of the journey, he drove at 131 km/h. Find the

0
549
4

Bernard drove for 6 hours at an average speed of 116 km/h to reach town. For the first 262 km of the journey, he drove at 131 km/h. Find the average speed of the remaining of the journey. (Round off your answer to 1 decimal place)

Guest May 23, 2014

#4
+93351
+5

okay,

Thank you for telling us that you didn't understand - We need your honest feed  back.  Just make sure you think really hard first.  But if you still don't understand - Always say so.

-----------------------------------------------------------------------

CPhill's answer is very good but I will try and break it down further.

First look at the whole trip.

6 hours at 116km/hr   will take the car 6*116 = 696km

So the whole trip is 696km and will take 6 hours.

--------------------------------------------------------------

Now I am going to look at the first part of the trip.

You travel 262km at a speed of 131km/hour

It will help if you understand that 131km/1hour is the same as 1hour/131km

That is if you go 131km in an hour then you must take 1 hour to travel 131km.

I want to know how long this part of the journey took.

$$\frac{1hour}{131km}\times\frac{262km}{1}$$

the km cancel out and you are left with     $$\frac{262}{131}hours=2 hours$$

So for this first stretch you travel 262km in 2 hours

-------------------------------------------------------------------------

Now you need to know the average speed for the second part of the trip.

speed = distance/time

So you need  distance and time taken.

The whole trip took 6 hours.  The first part took 2 hours.  So the second part must have taketn 6-2=4 ours

I worked out that the whole distance was 696km.  The first part was 262km.  So the second part has to be 696-262=434km

Speed for the second part is 434km/4hours = 108.5Km/hour

--------------------------------------------------------------------------

I hope that that helps.

Melody  May 24, 2014
#1
+88898
+5

If he drove 6 hrs. at 116km/hr., the total length of the trip was 6hrs * 116km = 696km

And he travels 262km in the first 2 hours. So the distance left to travel in the last four hours was :The total distance traveled (696) -  the distance already traveled (262) = 434km

So, the final 4 hrs Bernard traveled 696 - 262 = 434km

And Distance/Time = Rate......... so

434km/4hrs = 108.5 km/hr

And that's the rate for the rest of the trip.

CPhill  May 23, 2014
#2
+11847
+5

sorry CPhill i actully cant understand ur answer proplerly ! im getting a bit confused ?

rosala  May 23, 2014
#3
+88898
0

What confused you??

CPhill  May 23, 2014
#4
+93351
+5

okay,

Thank you for telling us that you didn't understand - We need your honest feed  back.  Just make sure you think really hard first.  But if you still don't understand - Always say so.

-----------------------------------------------------------------------

CPhill's answer is very good but I will try and break it down further.

First look at the whole trip.

6 hours at 116km/hr   will take the car 6*116 = 696km

So the whole trip is 696km and will take 6 hours.

--------------------------------------------------------------

Now I am going to look at the first part of the trip.

You travel 262km at a speed of 131km/hour

It will help if you understand that 131km/1hour is the same as 1hour/131km

That is if you go 131km in an hour then you must take 1 hour to travel 131km.

I want to know how long this part of the journey took.

$$\frac{1hour}{131km}\times\frac{262km}{1}$$

the km cancel out and you are left with     $$\frac{262}{131}hours=2 hours$$

So for this first stretch you travel 262km in 2 hours

-------------------------------------------------------------------------

Now you need to know the average speed for the second part of the trip.

speed = distance/time

So you need  distance and time taken.

The whole trip took 6 hours.  The first part took 2 hours.  So the second part must have taketn 6-2=4 ours

I worked out that the whole distance was 696km.  The first part was 262km.  So the second part has to be 696-262=434km

Speed for the second part is 434km/4hours = 108.5Km/hour

--------------------------------------------------------------------------

I hope that that helps.

Melody  May 24, 2014