Skip to main content

Posts

Simple Diffusion Model with Checkerboard Data

I have been trying to build a simple diffusion model with checker board data which is made from dots (x, y). So it is 2d data. def get_noise_level(step, total_steps, max_noise_level=1.0): # Define the mean and standard deviation for the Gaussian distribution mean = total_steps / 2 std_dev = total_steps / 4 # This can be adjusted based on desired spread # Calculate the Gaussian noise level gaussian_noise_level = np.exp(-((step - mean) ** 2) / (2 * std_dev ** 2)) # Scale the noise level to be between 0 and max_noise_level return gaussian_noise_level * max_noise_level Above is my func. to get the noise level # Model definition class DiffusionModel(nn.Module): def __init__(self): super().__init__() self.fc1 = nn.Linear(2, 128) self.fc2 = nn.Linear(128, 128) self.fc3 = nn.Linear(128, 2) def forward(self, x): x = torch.relu(self.fc1(x)) x = torch.relu(self.fc2(x)) return self.fc3(x) Above is m

RuntimeError: Given groups=1, weight of size [64, 64, 5, 5, 5], expected input[1, 16, 64, 8, 8] to have 64 channels, but got 16 channels instead

Hello i use pytorch to make a CNN with Cirfar data. And I got this error. class Net(nn.Module): def init (self): super(Net, self). init () self.conv1 = nn.Conv2d( in_channels = 3, out_channels = 32, kernel_size = 5, stride = 1, padding = 2 ) self.conv2 = nn.Conv2d( in_channels=32, out_channels=64, kernel_size=5, stride=1, padding=2 ) self.conv3 = nn.Conv3d( in_channels=64, out_channels=64, kernel_size=5, stride=1, padding=2 ) self.pool = nn.MaxPool2d(2,2) self.fc1 = nn.Linear(1024, 0) self.fc2 = nn.Linear(0, 1024) self.fc3 = nn.Linear(1024, 10) def forward(self, x): x = self.pool(F.relu(self.conv1(x))) x = self.pool(F.relu(self.conv2(x))) print('x_shape:',x.shape) x = self.pool(F.relu(self.conv3(x))) x = torch.flatten(x, 1) # flatten all dimensions except batch x = F.relu(self.fc1(x)) x = F.relu(self.fc2(x)) x = self.fc3(x) return (x) model = Net() count_parameters(model) model.to(device) criterion = nn.CrossEntropyLoss() optimizer = opti

Struggling with some first steps(unluckily i didn't manage to find out the solution on my own) [closed]

enter image description here [WinError 2] The system cannot find the file specified [cmd: ['py', '-m', 'py_compile', 'C:\Users\Administrator\Desktop\python\hello_world.py']] [dir: C:\Users\Administrator\Desktop\python] [path: C:\Program Files (x86)\VMware\VMware Workstation\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\PC Connectivity Solution;C:\app\Administrator\product\12.1.0\client;C:\app\Administrator\product\12.1.0\client\bin;C:\app\Administrator\product\12.1.0\client_1;C:\app\Administrator\product\12.1.0\client_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE;c:\Pro

Tkinter (or CustomTkinter) scrollbar transparency

I want to hide scrollbar in CTkScrollableFrame, or at least make it transparent. Anticipating your question, I need to be able to scroll my frame with mouse wheel, so I don't need to see the scroll button. Is there any way to do it? I just read wiki for both Ctk and Tkinter, and didn't find the answer. source https://stackoverflow.com/questions/77671526/tkinter-or-customtkinter-scrollbar-transparency

Flask blueprints with SQLAlchemy for APIs -- what can I do to simplify?

I am designing an app that has a database, a CRUD web interface to manage its content, and exposing a REST API to be called by an external UI written in React. I am using native Flask Blueprints, SQLAlchemy, along with Marshmallow for API serialization. The way I have structured Blueprints, based on what I learned from the Flask docs, seems unnecessarily complicated: app.py -> __init__.py . create_app() registers blueprints "factory" Flask pattern each blueprint imports from a routes module register_blueprint specifies two blueprints one for HTML, another for API as each has a different url_prefix each routes module __init__.py imports Blueprint, then creates the blueprint instances for html and api, then imports the actual routes for the module (e.g. from routes.user import routes ) each routes implementation imports the blueprints created in the module imports the SQLAlchemy model and Marshmallow schema creates the code for the routes, and decora

onClick(props.function()) Causes Function Calls repetedly [duplicate]

I am trying to display different things depending if a element is clicked or not in a navbar, in body.main App.js content: const [showCatContent, setShowCatContent] = useState(false); const toggleCatContent = () => { setShowCatContent(!showCatContent); }; console.log(showCatContent) return ( <html><head> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script defer src="theme.js"></script> <link rel="stylesheet" href="style.css" /> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700&display=swap" rel="stylesheet" /> </head> <body> <Navbar toggleCatContent={toggleCatContent} /> <body> <Navbar toggleCatContent={toggleCatContent} /> <main> {showCatContent ? ( <p>This is my cat ahahhahahah

CS50P Issue - Little Professor "displays EEE when answer is incorrect" and "shows solution after 3 incorrect attempts"

I'm brand new to programming taking the CS50P course. In the Little Professor assignment in Pset4 I am passing all the Check50 tests except the last two. Running my code manually yields all the expected results per the problem sample video. I am guessing that I have some type of operations order that gives the right result but check50 is not interpreting it as needed. Here is my code: import random def main(): score = 0 level = get_level() for _ in range(10): x, y, correct_answer = generate_problem(level) user_attempts = 0 while user_attempts < 3: print(f"{x} + {y} = ", end="") user_answer = get_user_input() if user_answer == correct_answer: score += 1 break else: user_attempts += 1 print("EEE") if user_attempts == 3: print(f"{x} + {y} = {correct_answer}") print(