Skip to content

Instantly share code, notes, and snippets.

@18520339
Last active December 29, 2023 09:18
Show Gist options
  • Save 18520339/3326071750767b72ee4d56f1eb22b88a to your computer and use it in GitHub Desktop.
Save 18520339/3326071750767b72ee4d56f1eb22b88a to your computer and use it in GitHub Desktop.
My study notes 2
# https://stackoverflow.com/questions/7992689/how-to-loop-over-files-in-natural-order-in-bash
# https://stackoverflow.com/questions/3211595/renaming-files-in-a-folder-to-sequential-numbers
readarray -d '' entries < <(printf '%s\0' *.png | sort -zV)
num=10846
for entry in "${entries[@]}"; do
new=$(printf "%07d.png" "$num") #07 pad to length of 7
mv -i -- "$entry" "$new"
echo "${entry} -> ${new}"
let num=num+1
done
#include <iostream>
#include <vector>
using namespace std;
class MySorter {
public:
virtual ~MySorter() { }
virtual void thucHien(vector<int> &a, bool tangDan = true) {
if (tangDan) thucHien(a, MySorter::soSanhTangDan);
else thucHien(a, MySorter::soSanhGiamDan);
}
protected:
static bool soSanhTangDan(int x, int y) { return x > y; }
static bool soSanhGiamDan(int x, int y) { return x < y; }
virtual void thucHien(vector<int> &a, bool (*soSanh)(int, int)) = 0;
};
class MyInterchangeSorter: public MySorter {
public:
void thucHien(vector<int> &a, bool (*soSanh)(int, int)) {
for (int i = 0; i < a.size(); ++i)
for (int j = i + 1; j < a.size(); ++j)
if (soSanh(a[i], a[j])) {
int tam = a[i];
a[i] = a[j];
a[j] = tam;
}
}
};
class MyBubbleSorter: public MySorter {
public:
void thucHien(vector<int> &a, bool (*soSanh)(int, int)) override {
for (int i = 0; i < a.size(); ++i)
for (int j = i + 1; j < a.size(); ++j)
if (soSanh(a[j - 1], a[j])) {
int tam = a[i];
a[i] = a[j];
a[j] = tam;
}
}
};
class DanhSach {
private:
vector<int> data;
public:
void nhap() {
int n = 0;
cout << "Nhap so luong phan tu: ";
cin >> n;
data.resize(n);
for (int i = 0; i < n; ++i)
cin >> data[i];
}
void hienThi() {
for (int &value: data)
cout << value << " ";
cout << endl;
}
void sapXep(MySorter *sorter, bool tangDan = true) {
sorter->thucHien(data, tangDan);
}
};
int main() {
DanhSach ds;
ds.nhap();
ds.hienThi();
ds.sapXep(new MyInterchangeSorter());
ds.sapXep(new MyBubbleSorter());
return 0;
}
@18520339
Copy link
Author

Why deep representations?

image image
The edges in this picture are grouped together with pixels to form edges. It can then detect the edges and group edges together to form parts of faces To compute XOR, the depth of the network will be on the order of log(N). We'll just have an XOR tree. So the number of nodes/circuit components/gates is not that large. If you're forced to compute this function with just 1 hidden layer -> This hidden layer will be exponentially large in the number of bits, because you need to exhaustively enumerate our 2^N possible configurations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment