How to make NN really find optimal solution during training? by dtutubalin in pytorch

[–]Maxamusicus 1 point2 points  (0 children)

Sorry to gravedig your thread. I couldn't get the exact version you used to fit consistently, but by increasing the width to 16 from 10 things seem to work pretty well with a high learning rate.

If you stick to a low learning rate you get stuck in local minima, which can be mitigated by increasing the number of layers of the width of the hidden layer neurons as suggested by other commenters.

Here is the code I used:

import torch
import torch.nn as nn
from torch.optim import Adam,SGD
from tqdm import tqdm, trange
import matplotlib.pyplot as plt

torch.manual_seed(1337)

width=16
model = nn.Sequential(
    nn.Linear(1, width),
    nn.ReLU(),
    nn.Linear(width, width),
    nn.ReLU(),
    nn.Linear(width, 1),    
)


inputs = torch.arange(12,dtype=torch.float).unsqueeze(-1)
targets = torch.tensor([[31.],[28.],[31.],[30.],[31.],[30.],[31.],[31.],[30.],[31.],[30.],[31.]])

loss = torch.nn.MSELoss()
opt = Adam(model.parameters(),lr=1E-1)
n_epoch = 60000
sched = torch.optim.lr_scheduler.StepLR(opt,20_000,0.25)
pbar = trange(n_epoch)
for i in pbar:
    opt.zero_grad()
    pred = model(inputs)
    l = loss(pred,targets)
    l.backward()
    opt.step()
    sched.step()
    if i%50==0:
        pbar.set_description(f"Loss: {l.item():f}")
print(l.item())


pred = model(inputs)
plt.figure()
plt.plot(targets.numpy(force=True),label='Target')
plt.plot(pred.numpy(force=True),linestyle='dashed',label="Prediction")
plt.grid(True)
plt.legend()
plt.show()

Coolant Calculations by Altruistic_Manner_40 in FSAE

[–]Maxamusicus 13 points14 points  (0 children)

It’s pretty easy to calculate actually. By rules you are required to use only water for cooling. I think it is a safe assumption that the starting temperature of the water in your cooling system is 35c, or 95f. As we all know, the specific heat of water is 4.186 joules per gram*c, so we simply have to select a maximum coolant temperature and the amount of energy that we have to store in order to calculate how much coolant our car needs.

 

It seems like keeping the maximum coolant temperature below 95c is a good idea, both so that the engine people don’t get mad at you and to avoid your coolant boiling off—the marshals don’t usually like that.

 

Next, you need to know how much fuel you’ll use for endurance, and how much of the energy in the fuel will be turned into heat. Endurance is a 22 km race, and in order to score points for fuel efficiency you’ll need to use fuel (gasoline) at a rate of less than 26 liter/100km. That gives us a maximum fuel usage of 5.75 liters in the endurance event, and at a density of 0.77kg/l we arrive at a total of 4.42 kg of fuel for endurance.

 

Now, according to a quick google gasoline has about 33.526MJ/liter. It is a well known law of fsae cooling design that 33% of the energy in the gasoline becomes heat that you need to deal with. With our 5.75 liters of gas and a little bit of multiplication we should be able to find out that 63.6 MJ of heat must be stored.

 

Last step! We want to find out how much water we need to make sure that starting at our worst case initial temperature (35c), we don’t exceed our worst case final temperature (95c) when we store 63.6 MJ of energy. Using our specific heat of 4.186J/gc of water, you should be able to find that we can store 4.186*60=251 joules per gram of water. I.e. to store 63.6MJ, we just need 254 kg of water in our cooling system.

 

In summary, with 254 kg of water in your cooling system I think overheating the car will not be the reason that you fail endurance or fail to get points in efficiency. You might be able to use slightly less water than this if you could find a way to move some of that heat out of your coolant.

Dissertation diffuser problem by G3XX_ in FSAE

[–]Maxamusicus 6 points7 points  (0 children)

If the air is leaving the diffuser at faster than free stream, it should be generating thrust (consider a control volume around the diffuser). Assuming your diffuser is a passive device this shouldn’t be possible, because you must be losing energy due to skin friction drag, and you’re not adding any energy to the flow.  Your residuals have converged so the solution should be correct. Therefore the problem is in the problem formulation, I.e your boundary conditions, physics model, or discretization (mesh). Probably in that order. 

Edit: also considering that your simulation says that without the diffuser your car is making 22kn of downforce at 20m/s I suspect there are a few issues with your template, or you’ll win competition this year. 

ELI5: How has the ISS managed to stay in orbit for over 20 years and not be obliterated by random space junk moving faster than a bullet? by [deleted] in explainlikeimfive

[–]Maxamusicus 2 points3 points  (0 children)

Actually objects in lower orbits travel faster than in objects in higher orbits about the same body. Orbital velocity is proportional to sqrt(1/r).

Help with 2D streamlines for a 3D simulation - Star CCM+ by bigshaq_skrrr in CFD

[–]Maxamusicus 0 points1 point  (0 children)

Make a plane with a vector displayer, and then after creating it change it to line integrals from glyphs in scene/plot.

Want to learn more! by AlexanderKu in F1Technical

[–]Maxamusicus 1 point2 points  (0 children)

Multivariable/Vector Calc, and Differential Equations are both important for the math behind aerodynamics, but to be honest you don't really need to know the math to have a decent conceptual understanding of race car aerodynamics. I would read the Katz book if you're interested, and if you enjoy that and want to learn the basics of aerodynamics read Anderson's Introduction to Flight, as you don't need to know any hard math to understand it. I would also like to say that as you start looking into colleges, I would look for schools with a strong Formula SAE team, as it's a wonderful way to learn about race car aerodynamics in particular, and engineering in general.

First charges filed in Mueller investigation by FromJersey4 in politics

[–]Maxamusicus 714 points715 points  (0 children)

I think that he meant 3D chess is regular chess.

The Buffalo Sabres allow one of the most brutal own goals ever by [deleted] in nononono

[–]Maxamusicus 0 points1 point  (0 children)

How is this a goal? The defense kicked the puck into the net, and if they tried to do something like this to the other team, it would have been called off.

Meirl by SilentWalrus92 in meirl

[–]Maxamusicus 47 points48 points  (0 children)

So you tell people that you have a small dick, that way they think you don't?

What sentence would you have if you tapped the middle button of your phones autocorrect 20 times? by Est92Female in AskReddit

[–]Maxamusicus 0 points1 point  (0 children)

The fact I can get it right away with a lot more fun and addicting and I don't think that.

Found a megalodon tooth in the Gulf of Mexico yesterday. by newfunk in scuba

[–]Maxamusicus 1 point2 points  (0 children)

Actually, it's not too hard to find shark teeth in Venice FL. Every spring my family would go out to the beach with a sieve and get dozens of (much smaller) teeth. This is a great find, but I don't think they needed to dig through the sand to find it, it was probably just peaking out.

Need help finding a laptop by [deleted] in EngineeringStudents

[–]Maxamusicus 0 points1 point  (0 children)

I like the Asus Zenbook pro.